MOS - IoT: Your Connected Fogponic System

About: We are a research, design and foresight company. We translate future uncertainties into present-day choices.

Intro: MOS - IoT: Your Connected Fogponic System

Mitigation of Shock by Superflux: Our website

This Instructables is the continuity of the Fogponic System one. Here, you will be able to have more option to measure the data from your greenhouses computer and control multiple operations like the water pump flow, the lights timing, the fan intensity, the foggers and all the other controllers you aspire to add to your Fogponic project.

Step 1: Install ESP 8266-01 Wifi Shield on the Arduino

Minimum material requirements:

  • Arduino MEGA 2560
  • ESP 8266-01 Shield
  • Smartphone
  • Wi-fi connection

Connection:

  • ARDUINO --- ESP 8266
  • 3V --- VCC
  • 3V --- CH_PD
  • GND --- GND
  • RX0 --- TX
  • TX0 --- RX

Step 2: Setup the ESP8266-12 Shield

Few steps to follow:

  1. After connecting the ESP866-91 shield to the Arduino you have to upload the Bareminimum example in order to delete the previous code in your board.
  2. Upload the code to the Arduino, open the Serial monitor, set the Baudrate to 115200 and set Both NL and CR.
  3. On the Serial Monitor, type the following command: AT. Normally, you’re supposed to receive the message «OK». If not, please interchange the following wires: RX and TX of the Arduino. Depending on the shield, the position of the receiver can be different.
  4. You will need to setup the MODE of your shield. It exists 3 different one: Station(1) AP Mode(2) and AP+Station(3). For MOS we just need to get the rst mode, type the following command: AT+CWMODE=1. If the shield is well set up, you will receive the message «OK». You can know in which MODE you are by typing: AR+CWMODE?
  5. To connect your ESP8266-01 to your Wi-Fi connection type: AT+CWJAP= “Wi-Fi network”,“Password”
  6. Well done! The MOS prototype is connected to the Internet. Now we need to connect the ESP8266 to an App.

Step 3: Setup the Wifi Connection

#include <AccelStepper.h>
#define BLYNK_PRINT Serial2 #include <BlynkSimpleShieldEsp8266_HardSer.h> #include <Esp8266_HardSer.h> #define EspSerial Serial2 ESP8266 wifi (EspSerial); char auth[] = «b02cfbbfd2b34fd1826ec0718613306c»; #include <SPI.h> #include <Ethernet.h>

void setup() { Serial2.begin(9600); delay(10); EspSerial.begin(115200); delay(10); Blynk.begin(auth, wifi , «USERNAME»,»PASSEWORD»); timer.setInterval(3000L, sendUp-time); }

void sendUptime() { Blynk.virtualWrite(V1, DHT.temperature); Blynk.virtualWrite(V2, DHT.humidity); Blynk.virtualWrite(23, m); }

void loop() { rtc.begin(); timer.run(); Blynk.run();

}
  1. Download and install the last Blynk library inside the library folder of your Arduino program.
  2. Download and install the last Blynk ESP8266 library in the library folder. It is possible that you need to change the esp8226.cp with another version.
  3. Install the BLYNK app on the Appstore or Google play store and create a new project.
  4. Copy/paste the code above on a new Arduino Sketch. You will need to change the char auth[] eld with the key authentication from your BLYNK project. The current MOS app key is «b02cfbbfd2b34fd1826ec0718613306c».
  5. Write you're wi board and your password on the following line: Blynk.begin(auth, wifi, «???»,«???»);.
  6. Run the Arduino sketch and open the Serial Monitor. Don’t forget to change the Baudrate to 115200 and the line coding to «Both NL and CR».
  7. After few seconds, the MOS Arduino will normally be connected to the internet. Now it’s time to create our MOS Blynk App!

Step 4: Learn and Apply BLYNK Language

Blynk is well adapted to the Arduino language. One of the particularities of Blynk is that is using Digital, Analog but also Virtual pins. Depending on the controller, sensor or fader you will need to write virtual lines on your Arduino app sketch.

  • Example of Virtual writing on the Arduino sketch: Blynk.virtualWrite(pin, action);
  • You can add all the widgets you want to the app by following the steps above.
  • But be aware that some of the sensors will need to have some amends on the original code to correlate with the BLYNK app.

Example, DHT-11 + BLYNK:

  1. Be sure to not put delay on the void setup code after the last delay(10); The timer.setInterval(1000,Senduptime) is using as a delay for the ESP8266-01 shield and not for the Serial monitor. You need to put a minimum of 1000 milliseconds to this delay or the ESP shield would struggle with sending and receiving information.
  2. You will need to update the DHT library for the Blynk app. For that, you can download the new DHT library by typing DHT.h and DHT11.h on google. There is some good Github repertory with the DHT library inside.
  3. The big change is residing on the void sendUptime() with the new DHT library you will just need to set the virtual pin you want with the condition you want: temperature or humidity. So, let’s see an example of the line you can write to send the humidity or temperature data to the Blynk app: Blynk.virtualWrite(V1, DHT.temperature);. Blynk.virtualWrite(virtual pin,sensor).
  4. The void loop() is getting two new conditions which are: Blynk.run(); and timer.run();. But also, even if you called the DHT in the below void which is functioning as a void loop() you will also need to call the sensor in the last void.

#include dht11 DHT;
#define DHT11_PIN A0 #include SimpleTimer timer; #include <SimpleTimer.h> #define BLYNK_PRINT Serial #include #include #de ne EspSerial Serial ESP8266 wi (EspSerial); char auth[] = «b02cfbbfd2b34fd1826ec0718613306c»; #include #include

void setup() { Serial2.begin(9600); delay(10); EspSerial.begin(115200); delay(10); timer.setInterval(1000, sendUptime); }

void sendUptime() { Blynk.virtualWrite(V1, DHT.temperature); Blynk.virtualWrite(V2, DHT.humidity); }

void loop() { int chk = DHT.read(DHT11_PIN); timer.run(); Blynk.run();

}

Share

    Recommendations

    • Fix It! Contest

      Fix It! Contest
    • Tiny Home Contest

      Tiny Home Contest
    • Audio Contest 2018

      Audio Contest 2018

    Discussions