Taillieu.Info

More Than a Hobby..

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /customers/3/2/5/taillieu.info/httpd.www/templates/taillieuinfo_joomla3_rev1/functions.php on line 194

sbm IoT curcus

https://codeshare.io/1IF6U


https://learn.sparkfun.com/tutorials/photon-redboard-hookup-guide


https://learn.sparkfun.com/tutorials/esp8266-thing-development-board-hookup-guide/example-sketch-blink-with-blynk


https://learn.sparkfun.com/tutorials/photon-redboard-hookup-guide


https://learn.sparkfun.com/tutorials/esp8266-thing-development-board-hookup-guide/example-sketch-blink-with-blynk


https://learn.sparkfun.com/tutorials/photon-redboard-hookup-guide


https://learn.sparkfun.com/tutorials/esp8266-thing-development-board-hookup-guide/example-sketch-blink-with-blynk

cyvnpnz9jm.database.windows.net;initial catalog=iotdatabase;user id=kurt;password=XXXXXX;MultipleActiveResultSets=True


var ctx = new iotdatabaseEntities();
ctx.IotDataTables.Add(new IotDataTable
{
DeviceId = request.DeviceId,
SensorType = request.SensorType,
SensorValue = request.SensorValue
});
ctx.SaveChanges();



<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no,shrink-to-fit=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
<title>Getting data from a json API</title>
<link rel="stylesheet" href="/https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.css" />
<script src="/https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="/https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>

<script src="/cordova.js"></script>

<script>console.log = hyper.log</script>

</head>
<body>
<script>

myURL = "http://nuboidvm1.cloudapp.net/api/ping"

function getJSON() {
if (window.cordova){
console.log('Using Apache Cordova HTTP GET function');
cordovaHTTP.get(
myURL,
function (response) {
console.log("Answer is " + JSON.parse(response.data))
document.getElementById('printHere').innerHTML += "Answer is " + JSON.parse(response.data) + '<br>';
},
function (error){
console.log(JSON.stringify(error));
});
}
else {
console.log('Not using Cordova, fallback to AJAX via jquery');
$.ajax({
url: myURL,
jsonp: "callback",
cache: true,
dataType: "jsonp",
data: {
page: 1
},
success: function(response){
console.log("Answer is " + JSON.parse(response.data))
document.getElementById('printHere').innerHTML += "Answer is " + JSON.parse(response.data) + '<br>';
}
});
}
}

</script><br />

<button onClick="getJSON();">Ping</button>
<div id="printHere"></div>
</body>
</html>

--------------------
https://learn.sparkfun.com/tutorials/esp8266-thing-development-board-hookup-guide/setting-up-arduino

/* Blink without Delay

Turns on and off a light emitting diode (LED) connected to a digital
pin, without using the delay() function. This means that other code
can run at the same time without being interrupted by the LED code.

The circuit:
* LED attached from pin 13 to ground.
* Note: on most Arduinos, there is already an LED on the board
that's attached to pin 13, so no hardware is needed for this example.

created 2005
by David A. Mellis
modified 8 Feb 2010
by Paul Stoffregen
modified 11 Nov 2013
by Scott Fitzgerald


This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
*/

// constants won't change. Used here to set a pin number :
const int ledPin = 13; // the number of the LED pin

// Variables will change :
int ledState = LOW; // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0; // will store last time LED was updated

// constants won't change :
const long interval = 1000; // interval at which to blink (milliseconds)

void setup() {
// set the digital pin as output:
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
}

void loop() {
// here is where you'd put code that needs to be running all the time.

// check to see if it's time to blink the LED; that is, if the
// difference between the current time and last time you blinked
// the LED is bigger than the interval at which you want to
// blink the LED.
unsigned long currentMillis = millis();

if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;

// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
Serial.println(ledState);
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}

see : https://learn.adafruit.com/esp8266-temperature-slash-humidity-webserver/code


///


#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

#define aref_voltage 3.3

const int LED_PIN = 5;
const int TEMP_PIN = A0;

const char WiFiSSID[] = "Syntra-wifi";
const char WiFiPSK[] = "";

long randomValue;

void setup() {
randomSeed(analogRead(0));
initHardware();
connectWiFi();
}

void loop() {

Serial.println();
Serial.println("--- BEGIN LOOP---");

uint8_t mac[WL_MAC_ADDR_LENGTH];
WiFi.macAddress(mac);
String macID = String(mac[WL_MAC_ADDR_LENGTH - 2], HEX) + String(mac[WL_MAC_ADDR_LENGTH - 1], HEX);
macID.toUpperCase();
String deviceId = "MyDevice" + macID;
Serial.println(" DeviceiId : " + deviceId );

//float temperatureC = getTemperature(TEMP_PIN);
float temperatureC =random(300);
//randomValue = random(300);

Serial.print(" temperatureC : " );
Serial.println(temperatureC);

HTTPClient http;
http.begin("http://nuboidvm1.cloudapp.net:81/api/thing");
http.addHeader("Content-Type", "application/json; charset=utf-8");
http.POST("{\"DeviceId\":\"" + deviceId +"\",\"SensorType\":\"TEMPERATURE\",\"SensorValue\":" + temperatureC + "}");
http.writeToStream(&Serial);
http.end();

Serial.println(" Post Succesfull!");

Serial.println("--- BEGIN LOOP---");
}

float getTemperature(int pin)
{
int reading = analogRead(pin);
float voltage = reading * 3.3;
voltage /= 1024.0;
float temperatureC = (voltage - 0.5) * 100 ;
return temperatureC;
}
void initHardware()
{
Serial.begin(9600);
pinMode(LED_PIN, OUTPUT); // Set LED as output
digitalWrite(LED_PIN, HIGH); // LED off
//analogReference(EXTERNAL);
}

void connectWiFi()
{
byte ledStatus = LOW;
Serial.println();
Serial.println("Connecting to: " + String(WiFiSSID));

WiFi.mode(WIFI_STA);
WiFi.begin(WiFiSSID, WiFiPSK);

while (WiFi.status() != WL_CONNECTED)
{
digitalWrite(LED_PIN, ledStatus);
ledStatus = (ledStatus == HIGH) ? LOW : HIGH;
delay(100);
}
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}


//------------
//To install in PC or MAC

nieuw code .... test

http://www.tightvnc.com
http://winscp.net/
//---------------------------------------------------

//Some Linux Commands

Change Keyboard
sudo raspi-config
Print System Information
uname -a
Shutdown
sudo shutdown -h now
Get IP Address ?
hostname –I
Start Desktop
startx
Install Mono
sudo apt-get update
sudo apt-get install mono-complete
sudo apt-get install mono-runtime
mozroots --import --ask-remove –machine
mono myprogram.exe
TightVNC Server
sudo apt-get install tightvncserver
tightvncserver
vncserver :0 -geometry 1920x1080 -depth 24


//Sites
https://www.adafruit.com/

// Code voor aanroepen van een URL (via HTTP GET)

using System;
using System.Net.Http;

namespace TestMono
{
class Program
{
static void Main(string[] args)
{
var httpClient = new HttpClient();

const string url = "http://xeoplanstorage.blob.core.windows.net/dataforraspberry/data.txt";

var started = DateTime.Now;
for (int i = 0; i < 200 ; i++)
{
var task = httpClient.GetAsync(url);
var result = task.Result;
result.Content.LoadIntoBufferAsync(1000000);
var content = result.Content.ReadAsStringAsync().Result;
Console.WriteLine(content);
Console.WriteLine(i.ToString());

}
var ended = DateTime.Now;
var diff = (ended - started).TotalMilliseconds;
Console.WriteLine("duurde " + diff);
Console.ReadKey();
}
}
}


//Voorbeeld van een POST
public async void Post(String url, DebugDto insightsDto)
{
var httpClient = new HttpClient();
var jsonToPost = JsonConvert.SerializeObject(insightsDto);


var task = httpClient.PostAsync(url, new StringContent(jsonToPost, Encoding.UTF8, "application/json"));
var result = await task;
result.EnsureSuccessStatusCode();

}


http://dev.tinkermode.com/img/docs/raspberry_pi/LED.png


https://github.com/raspberry-sharp/raspberry-sharp-io

using Raspberry.IO.GeneralPurpose

var led1 = ConnectorPin.P1Pin07.Output();

var connection = new GpioConnection(led1);
while (true)
{
connection.Toggle(led1);
System.Threading.Thread.Sleep(250);
}

connection.Close();

//-------------


var led1 = ConnectorPin.P1Pin07.Output();

var connection = new GpioConnection(led1);

var httpClient = new HttpClient();

const string url = "http://xeoplanstorage.blob.core.windows.net/dataforraspberry/data.txt";


while (true)
{
var task = httpClient.GetAsync(url);
var result = task.Result;
result.Content.LoadIntoBufferAsync(1000000);
var content = result.Content.ReadAsStringAsync().Result;
Console.WriteLine(content);
if (content == "1")
{
connection.Pins[led1].Enabled = true;
}
if (content == "0")
{
connection.Pins[led1].Enabled = false;
}

}

//Hoe een file naar Azure opaden

Lees
https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/

gebruik : http://www.cloudberrylab.com/free-microsoft-azure-explorer.aspx

using Microsoft.WindowsAzure.Storage;


var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=xeoplanstorage;AccountKey=Nhquua6CzZnae2K/8kclXLxbpQY3NfybpJU/xuGxqaooOStTS3UX6XoASbm4kkDSuhKxZ9vepbmo2dZOvnS/Mg==");

var blobClient = storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference("dataforraspberry");

var blockBlob = container.GetBlockBlobReference("kurt.txt");

blockBlob.UploadText("0");


//// EEN API

[Route("api/ping")]
public class PingController : ApiController
{
public IHttpActionResult Get()
{
Console.WriteLine("Ping called");
return Ok("Pong from cloud");
}
}

//
using System;
using System.Web.Http;
using Microsoft.Owin.Hosting;
using Owin;

namespace IOTAPI
{
class Program
{
static void Main(string[] args)
{
var startOptions = new StartOptions("http://localhost");
WebApp.Start<Startup>(startOptions);
Console.ReadKey();
}
}

public class Startup
{
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
config.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
config.MapHttpAttributeRoutes();
app.UseWebApi(config);
}
}
}


/// de config

<?xml version="1.0" encoding="utf-8"?>
<configuration>

<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no,shrink-to-fit=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
<title>Getting data from a json API</title>
<link rel="stylesheet" href="/https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.css" />
<script src="/https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="/https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>

<script src="/cordova.js"></script>

<script>console.log = hyper.log</script>

</head>
<body>
<script>

myURL = "http://nuboidvm1.cloudapp.net/api/ping"

function getJSON() {
if (window.cordova){
console.log('Using Apache Cordova HTTP GET function');
cordovaHTTP.get(
myURL,
function (response) {
console.log("Answer is " + JSON.parse(response.data))
document.getElementById('printHere').innerHTML += "Answer is " + JSON.parse(response.data) + '<br>';
},
function (error){
console.log(JSON.stringify(error));
});
}
else {
console.log('Not using Cordova, fallback to AJAX via jquery');
$.ajax({
url: myURL,
jsonp: "callback",
cache: true,
dataType: "jsonp",
data: {
page: 1
},
success: function(response){
console.log("Answer is " + JSON.parse(response.data))
document.getElementById('printHere').innerHTML += "Answer is " + JSON.parse(response.data) + '<br>';
}
});
}
}

</script><br />

<button onClick="getJSON();">Ping</button>
<div id="printHere"></div>
</body>
</html>

--------------------
https://learn.sparkfun.com/tutorials/esp8266-thing-development-board-hookup-guide/setting-up-arduino

/* Blink without Delay

Turns on and off a light emitting diode (LED) connected to a digital
pin, without using the delay() function. This means that other code
can run at the same time without being interrupted by the LED code.

The circuit:
* LED attached from pin 13 to ground.
* Note: on most Arduinos, there is already an LED on the board
that's attached to pin 13, so no hardware is needed for this example.

created 2005
by David A. Mellis
modified 8 Feb 2010
by Paul Stoffregen
modified 11 Nov 2013
by Scott Fitzgerald


This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
*/

// constants won't change. Used here to set a pin number :
const int ledPin = 13; // the number of the LED pin

// Variables will change :
int ledState = LOW; // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0; // will store last time LED was updated

// constants won't change :
const long interval = 1000; // interval at which to blink (milliseconds)

void setup() {
// set the digital pin as output:
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
}

void loop() {
// here is where you'd put code that needs to be running all the time.

// check to see if it's time to blink the LED; that is, if the
// difference between the current time and last time you blinked
// the LED is bigger than the interval at which you want to
// blink the LED.
unsigned long currentMillis = millis();

if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;

// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
Serial.println(ledState);
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}

see : https://learn.adafruit.com/esp8266-temperature-slash-humidity-webserver/code


///


#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

#define aref_voltage 3.3

const int LED_PIN = 5;
const int TEMP_PIN = A0;

const char WiFiSSID[] = "Syntra-wifi";
const char WiFiPSK[] = "";

long randomValue;

void setup() {
randomSeed(analogRead(0));
initHardware();
connectWiFi();
}

void loop() {

Serial.println();
Serial.println("--- BEGIN LOOP---");

uint8_t mac[WL_MAC_ADDR_LENGTH];
WiFi.macAddress(mac);
String macID = String(mac[WL_MAC_ADDR_LENGTH - 2], HEX) + String(mac[WL_MAC_ADDR_LENGTH - 1], HEX);
macID.toUpperCase();
String deviceId = "MyDevice" + macID;
Serial.println(" DeviceiId : " + deviceId );

//float temperatureC = getTemperature(TEMP_PIN);
float temperatureC =random(300);
//randomValue = random(300);

Serial.print(" temperatureC : " );
Serial.println(temperatureC);

HTTPClient http;
http.begin("http://nuboidvm1.cloudapp.net:81/api/thing");
http.addHeader("Content-Type", "application/json; charset=utf-8");
http.POST("{\"DeviceId\":\"" + deviceId +"\",\"SensorType\":\"TEMPERATURE\",\"SensorValue\":" + temperatureC + "}");
http.writeToStream(&Serial);
http.end();

Serial.println(" Post Succesfull!");

Serial.println("--- BEGIN LOOP---");
}

float getTemperature(int pin)
{
int reading = analogRead(pin);
float voltage = reading * 3.3;
voltage /= 1024.0;
float temperatureC = (voltage - 0.5) * 100 ;
return temperatureC;
}
void initHardware()
{
Serial.begin(9600);
pinMode(LED_PIN, OUTPUT); // Set LED as output
digitalWrite(LED_PIN, HIGH); // LED off
//analogReference(EXTERNAL);
}

void connectWiFi()
{
byte ledStatus = LOW;
Serial.println();
Serial.println("Connecting to: " + String(WiFiSSID));

WiFi.mode(WIFI_STA);
WiFi.begin(WiFiSSID, WiFiPSK);

while (WiFi.status() != WL_CONNECTED)
{
digitalWrite(LED_PIN, ledStatus);
ledStatus = (ledStatus == HIGH) ? LOW : HIGH;
delay(100);
}
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}


//------------
//To install in PC or MAC

nieuw code .... test

http://www.tightvnc.com
http://winscp.net/
//---------------------------------------------------

//Some Linux Commands

Change Keyboard
sudo raspi-config
Print System Information
uname -a
Shutdown
sudo shutdown -h now
Get IP Address ?
hostname –I
Start Desktop
startx
Install Mono
sudo apt-get update
sudo apt-get install mono-complete
sudo apt-get install mono-runtime
mozroots --import --ask-remove –machine
mono myprogram.exe
TightVNC Server
sudo apt-get install tightvncserver
tightvncserver
vncserver :0 -geometry 1920x1080 -depth 24


//Sites
https://www.adafruit.com/

// Code voor aanroepen van een URL (via HTTP GET)

using System;
using System.Net.Http;

namespace TestMono
{
class Program
{
static void Main(string[] args)
{
var httpClient = new HttpClient();

const string url = "http://xeoplanstorage.blob.core.windows.net/dataforraspberry/data.txt";

var started = DateTime.Now;
for (int i = 0; i < 200 ; i++)
{
var task = httpClient.GetAsync(url);
var result = task.Result;
result.Content.LoadIntoBufferAsync(1000000);
var content = result.Content.ReadAsStringAsync().Result;
Console.WriteLine(content);
Console.WriteLine(i.ToString());

}
var ended = DateTime.Now;
var diff = (ended - started).TotalMilliseconds;
Console.WriteLine("duurde " + diff);
Console.ReadKey();
}
}
}


//Voorbeeld van een POST
public async void Post(String url, DebugDto insightsDto)
{
var httpClient = new HttpClient();
var jsonToPost = JsonConvert.SerializeObject(insightsDto);


var task = httpClient.PostAsync(url, new StringContent(jsonToPost, Encoding.UTF8, "application/json"));
var result = await task;
result.EnsureSuccessStatusCode();

}


http://dev.tinkermode.com/img/docs/raspberry_pi/LED.png


https://github.com/raspberry-sharp/raspberry-sharp-io

using Raspberry.IO.GeneralPurpose

var led1 = ConnectorPin.P1Pin07.Output();

var connection = new GpioConnection(led1);
while (true)
{
connection.Toggle(led1);
System.Threading.Thread.Sleep(250);
}

connection.Close();

//-------------


var led1 = ConnectorPin.P1Pin07.Output();

var connection = new GpioConnection(led1);

var httpClient = new HttpClient();

const string url = "http://xeoplanstorage.blob.core.windows.net/dataforraspberry/data.txt";


while (true)
{
var task = httpClient.GetAsync(url);
var result = task.Result;
result.Content.LoadIntoBufferAsync(1000000);
var content = result.Content.ReadAsStringAsync().Result;
Console.WriteLine(content);
if (content == "1")
{
connection.Pins[led1].Enabled = true;
}
if (content == "0")
{
connection.Pins[led1].Enabled = false;
}

}

//Hoe een file naar Azure opaden

Lees
https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/

gebruik : http://www.cloudberrylab.com/free-microsoft-azure-explorer.aspx

using Microsoft.WindowsAzure.Storage;


var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=xeoplanstorage;AccountKey=Nhquua6CzZnae2K/8kclXLxbpQY3NfybpJU/xuGxqaooOStTS3UX6XoASbm4kkDSuhKxZ9vepbmo2dZOvnS/Mg==");

var blobClient = storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference("dataforraspberry");

var blockBlob = container.GetBlockBlobReference("kurt.txt");

blockBlob.UploadText("0");


//// EEN API

[Route("api/ping")]
public class PingController : ApiController
{
public IHttpActionResult Get()
{
Console.WriteLine("Ping called");
return Ok("Pong from cloud");
}
}

//
using System;
using System.Web.Http;
using Microsoft.Owin.Hosting;
using Owin;

namespace IOTAPI
{
class Program
{
static void Main(string[] args)
{
var startOptions = new StartOptions("http://localhost");
WebApp.Start<Startup>(startOptions);
Console.ReadKey();
}
}

public class Startup
{
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
config.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
config.MapHttpAttributeRoutes();
app.UseWebApi(config);
}
}
}


/// de config

<?xml version="1.0" encoding="utf-8"?>
<configuration>

<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no,shrink-to-fit=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
<title>Getting data from a json API</title>
<link rel="stylesheet" href="/https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.css" />
<script src="/https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="/https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>

<script src="/cordova.js"></script>

<script>console.log = hyper.log</script>

</head>
<body>
<script>

myURL = "http://nuboidvm1.cloudapp.net/api/ping"

function getJSON() {
if (window.cordova){
console.log('Using Apache Cordova HTTP GET function');
cordovaHTTP.get(
myURL,
function (response) {
console.log("Answer is " + JSON.parse(response.data))
document.getElementById('printHere').innerHTML += "Answer is " + JSON.parse(response.data) + '<br>';
},
function (error){
console.log(JSON.stringify(error));
});
}
else {
console.log('Not using Cordova, fallback to AJAX via jquery');
$.ajax({
url: myURL,
jsonp: "callback",
cache: true,
dataType: "jsonp",
data: {
page: 1
},
success: function(response){
console.log("Answer is " + JSON.parse(response.data))
document.getElementById('printHere').innerHTML += "Answer is " + JSON.parse(response.data) + '<br>';
}
});
}
}

</script><br />

<button onClick="getJSON();">Ping</button>
<div id="printHere"></div>
</body>
</html>

--------------------
https://learn.sparkfun.com/tutorials/esp8266-thing-development-board-hookup-guide/setting-up-arduino

/* Blink without Delay

Turns on and off a light emitting diode (LED) connected to a digital
pin, without using the delay() function. This means that other code
can run at the same time without being interrupted by the LED code.

The circuit:
* LED attached from pin 13 to ground.
* Note: on most Arduinos, there is already an LED on the board
that's attached to pin 13, so no hardware is needed for this example.

created 2005
by David A. Mellis
modified 8 Feb 2010
by Paul Stoffregen
modified 11 Nov 2013
by Scott Fitzgerald


This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
*/

// constants won't change. Used here to set a pin number :
const int ledPin = 13; // the number of the LED pin

// Variables will change :
int ledState = LOW; // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0; // will store last time LED was updated

// constants won't change :
const long interval = 1000; // interval at which to blink (milliseconds)

void setup() {
// set the digital pin as output:
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
}

void loop() {
// here is where you'd put code that needs to be running all the time.

// check to see if it's time to blink the LED; that is, if the
// difference between the current time and last time you blinked
// the LED is bigger than the interval at which you want to
// blink the LED.
unsigned long currentMillis = millis();

if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;

// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
Serial.println(ledState);
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}

see : https://learn.adafruit.com/esp8266-temperature-slash-humidity-webserver/code


///


#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

#define aref_voltage 3.3

const int LED_PIN = 5;
const int TEMP_PIN = A0;

const char WiFiSSID[] = "Syntra-wifi";
const char WiFiPSK[] = "";

long randomValue;

void setup() {
randomSeed(analogRead(0));
initHardware();
connectWiFi();
}

void loop() {

Serial.println();
Serial.println("--- BEGIN LOOP---");

uint8_t mac[WL_MAC_ADDR_LENGTH];
WiFi.macAddress(mac);
String macID = String(mac[WL_MAC_ADDR_LENGTH - 2], HEX) + String(mac[WL_MAC_ADDR_LENGTH - 1], HEX);
macID.toUpperCase();
String deviceId = "MyDevice" + macID;
Serial.println(" DeviceiId : " + deviceId );

//float temperatureC = getTemperature(TEMP_PIN);
float temperatureC =random(300);
//randomValue = random(300);

Serial.print(" temperatureC : " );
Serial.println(temperatureC);

HTTPClient http;
http.begin("http://nuboidvm1.cloudapp.net:81/api/thing");
http.addHeader("Content-Type", "application/json; charset=utf-8");
http.POST("{\"DeviceId\":\"" + deviceId +"\",\"SensorType\":\"TEMPERATURE\",\"SensorValue\":" + temperatureC + "}");
http.writeToStream(&Serial);
http.end();

Serial.println(" Post Succesfull!");

Serial.println("--- BEGIN LOOP---");
}

float getTemperature(int pin)
{
int reading = analogRead(pin);
float voltage = reading * 3.3;
voltage /= 1024.0;
float temperatureC = (voltage - 0.5) * 100 ;
return temperatureC;
}
void initHardware()
{
Serial.begin(9600);
pinMode(LED_PIN, OUTPUT); // Set LED as output
digitalWrite(LED_PIN, HIGH); // LED off
//analogReference(EXTERNAL);
}

void connectWiFi()
{
byte ledStatus = LOW;
Serial.println();
Serial.println("Connecting to: " + String(WiFiSSID));

WiFi.mode(WIFI_STA);
WiFi.begin(WiFiSSID, WiFiPSK);

while (WiFi.status() != WL_CONNECTED)
{
digitalWrite(LED_PIN, ledStatus);
ledStatus = (ledStatus == HIGH) ? LOW : HIGH;
delay(100);
}
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}


//------------
//To install in PC or MAC

nieuw code .... test

http://www.tightvnc.com
http://winscp.net/
//---------------------------------------------------

//Some Linux Commands

Change Keyboard
sudo raspi-config
Print System Information
uname -a
Shutdown
sudo shutdown -h now
Get IP Address ?
hostname –I
Start Desktop
startx
Install Mono
sudo apt-get update
sudo apt-get install mono-complete
sudo apt-get install mono-runtime
mozroots --import --ask-remove –machine
mono myprogram.exe
TightVNC Server
sudo apt-get install tightvncserver
tightvncserver
vncserver :0 -geometry 1920x1080 -depth 24


//Sites
https://www.adafruit.com/

// Code voor aanroepen van een URL (via HTTP GET)

using System;
using System.Net.Http;

namespace TestMono
{
class Program
{
static void Main(string[] args)
{
var httpClient = new HttpClient();

const string url = "http://xeoplanstorage.blob.core.windows.net/dataforraspberry/data.txt";

var started = DateTime.Now;
for (int i = 0; i < 200 ; i++)
{
var task = httpClient.GetAsync(url);
var result = task.Result;
result.Content.LoadIntoBufferAsync(1000000);
var content = result.Content.ReadAsStringAsync().Result;
Console.WriteLine(content);
Console.WriteLine(i.ToString());

}
var ended = DateTime.Now;
var diff = (ended - started).TotalMilliseconds;
Console.WriteLine("duurde " + diff);
Console.ReadKey();
}
}
}


//Voorbeeld van een POST
public async void Post(String url, DebugDto insightsDto)
{
var httpClient = new HttpClient();
var jsonToPost = JsonConvert.SerializeObject(insightsDto);


var task = httpClient.PostAsync(url, new StringContent(jsonToPost, Encoding.UTF8, "application/json"));
var result = await task;
result.EnsureSuccessStatusCode();

}


http://dev.tinkermode.com/img/docs/raspberry_pi/LED.png


https://github.com/raspberry-sharp/raspberry-sharp-io

using Raspberry.IO.GeneralPurpose

var led1 = ConnectorPin.P1Pin07.Output();

var connection = new GpioConnection(led1);
while (true)
{
connection.Toggle(led1);
System.Threading.Thread.Sleep(250);
}

connection.Close();

//-------------


var led1 = ConnectorPin.P1Pin07.Output();

var connection = new GpioConnection(led1);

var httpClient = new HttpClient();

const string url = "http://xeoplanstorage.blob.core.windows.net/dataforraspberry/data.txt";


while (true)
{
var task = httpClient.GetAsync(url);
var result = task.Result;
result.Content.LoadIntoBufferAsync(1000000);
var content = result.Content.ReadAsStringAsync().Result;
Console.WriteLine(content);
if (content == "1")
{
connection.Pins[led1].Enabled = true;
}
if (content == "0")
{
connection.Pins[led1].Enabled = false;
}

}

//Hoe een file naar Azure opaden

Lees
https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/

gebruik : http://www.cloudberrylab.com/free-microsoft-azure-explorer.aspx

using Microsoft.WindowsAzure.Storage;


var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=xeoplanstorage;AccountKey=Nhquua6CzZnae2K/8kclXLxbpQY3NfybpJU/xuGxqaooOStTS3UX6XoASbm4kkDSuhKxZ9vepbmo2dZOvnS/Mg==");

var blobClient = storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference("dataforraspberry");

var blockBlob = container.GetBlockBlobReference("kurt.txt");

blockBlob.UploadText("0");


//// EEN API

[Route("api/ping")]
public class PingController : ApiController
{
public IHttpActionResult Get()
{
Console.WriteLine("Ping called");
return Ok("Pong from cloud");
}
}

//
using System;
using System.Web.Http;
using Microsoft.Owin.Hosting;
using Owin;

namespace IOTAPI
{
class Program
{
static void Main(string[] args)
{
var startOptions = new StartOptions("http://localhost");
WebApp.Start<Startup>(startOptions);
Console.ReadKey();
}
}

public class Startup
{
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
config.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
config.MapHttpAttributeRoutes();
app.UseWebApi(config);
}
}
}


/// de config

<?xml version="1.0" encoding="utf-8"?>
<configuration>

<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>