Fireduino Buy

Dual-Core Cortex-M3 processor, integrated high-quality audio Codec and WiFi module, have IOT expansion performance, perfectly compatible with the Arduino interface and Arduino IDE programming, and supports FireBlock graphics programming.

IOT Demo

Update time:2018-04-13 Views:6085

Fireduino and IOT

 Fireduino onboard WIFI,has a perfect network interface,very suitable for the IOT application scenarios which need to WIFI networking features.In this paper,combined with the YEELINK open the IOT platform as an example,show how to quickly use Fireduino to build IOT.

Fireduino and YeeLink

   YeeLink IOT cloud platform can provide sensor cloud services.And through real time data processing,to provide safe and reliable condition monitoring.
  YEELINK support Library download:https://github.com/qinqingege/YeeLinkLib.git
  After download,extract the libraries directory of the arduino.

Fireduino realize remote control

  If you connect the WIFI network with Fireduino,you can refer to the following WIKI:  http://wiki.t-firefly.com/index.php/Fireduino/WiFi_Connect
  
 In the case,the state of the switch in the YeeLink cloud device is realized,and when the switch state is opened,the Fireduino opens the relay.
  When this switch is close,Fireduino shut relay,and the remote network control of the relay is realized.
#include <WiFi.h>#include <SPI.h>#include <yl_data_point.h>#include <yl_device.h>#include <yl_wifi_client.h>#include <yl_messenger.h>#include <yl_sensor.h>#include <yl_value_data_point.h>#include <yl_sensor.h>//replace 2633 3539 with ur device id and sensor idyl_device ardu(15305);yl_sensor myswitch(26214, &ardu);//replace first param value with ur u-apikeyyl_wifi_client client;yl_messenger messenger(&client, "bb3f47349e887b7b6b08059a120cebe3", "api.yeelink.net");int status = WL_IDLE_STATUS;char ssid[] = "Fireduino";     //  your network SSID (name)char pass[] = "12345678";  // your network passwordint keyIndex = 0;            // your network key Index number (needed only for WEP)int switch_pin = 5;int led_pin = 3;int led_status = 0; void setup(){
  Serial.begin(115200); //for output information
  pinMode(switch_pin, OUTPUT);
  digitalWrite(switch_pin, HIGH); 
  pinMode(led_pin, OUTPUT);
  digitalWrite(led_pin, HIGH);
  conectWifi();} void loop(){updateYeelinkSwitch();delay(1000);if (led_status == 1)  led_status = 0;else 
      led_status = 1;digitalWrite(led_pin, led_status);} int lastStatus = 3;void updateYeelinkSwitch(){
  yl_value_data_point dp2;
  Serial.println("enter updateYeelinkSwitch"); 
  int ret = myswitch.single_get(messenger, dp2);
  if (ret == true)
  {int curStatus = dp2.get_value();if (curStatus != lastStatus){  if (curStatus == 0)  {  Serial.println("turn off the LED"); 
          digitalWrite(switch_pin, HIGH);  }  else if (curStatus == 1)  {  Serial.println("turn on the LED"); 
          digitalWrite(switch_pin, LOW);  }  lastStatus = curStatus;}
  }
  Serial.println("exit updateYeelinkSwitch"); } void conectWifi(){
  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {Serial.println("WiFi shield not present");// don't continue:while (true);
  }
  String fv = WiFi.firmwareVersion();
  if (fv != "1.1.0") {Serial.println("Please upgrade the firmware");
  }
  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {Serial.print("Attempting to connect to SSID: ");Serial.println(ssid);// Connect to WPA/WPA2 network. Change this line if using open or WEP network:status = WiFi.begin(ssid, pass);
  // wait 10 seconds for connection:delay(10000);
  }
  Serial.println("Connected to wifi");
  printWifiStatus();} void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());
  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");}