In a first step I will make a prototype for my sensor board. Usually you build a prototype just on a breadboard. But I would like to use my prototype for some weeks to see how my sensors work and how much energy is needed. Therefore I use a prototype circuit board instead.
My shopping list for that:
- ESP8266 Esp-12 Remote Serial Port WIFI Module with IO adapter plate Expansion
- XCSOURCE FT232RL 3.3V 5.5V FTDI USB zu TTL Serielles Adaptermodul Arduino Mini Anschluss TE203
- MTS1EU Greenhouse Sensor Kit Soil Hygrometer Module and DHT11 Temperature/Humidity Module for Arduino. Gewächshaus Pflazen
Additionally I need:
- A prototype circuit board
- 3 pcs. 10k Resistors (can be even bigger as long aa all 3 are equal)
- 1 electrolytic capacitor (>500uF)
- 1 Transisotr (e.g. BC547C)
- 1 3K3 Resistor
- a pin header
- a jumper
- a soldering iron
I know that there a many statements about the right soldering iron in the internet but for me personally a cheap soldering station is more than enough. There is also a good desoldering pump coming with the station and every beginner will need it. If you have too much money then spend it in a quite good solder. As power supply I use a USB powerbank that I’ve received as a giveaway. You can also get one for less than 10€ (e.g. here)
I try to do not solder items directly when building a prototype. Therefore I use pin headers. The disadvantage is that the prototype is not that robust but the advantage is I can easily borrow some parts without taking the soldering iron.
The ESP8266 just takes 3.3V so I take the USB to TTL converter also as voltage converter. Be sure to put the jumper to 3.3V. To safe energy I will put my ESP in deep-sleep. To prevent my sensors taking power when they are not used I use a transistor to power them on only when needed. The ESP needs quite a high current when connecting to the WLAN. I use an electrolytic capacitor parallel to the voltage supply. Sizing of that is no rocket science, it should be somewhere between 400uF and 2200uF (6-10V). For programming the ESP the CH_PD Pin has to be put on ground. Some recommend a button for that but I prefer a jumper.
The manual for the ESP8266 says that for wake up from deep-sleep pin 16 has to be connected to CH_PD. Unfortunately for some reasons this is not working with mine. I use the RESET for the wakeup instead. This prevents using some options for wakeup but I don’t care for the prototype.
It is a puzzle to place all the components on the board. I tried to save as much space because I had a small leftover to be used.
For programming my ESP I use the Arduio IDE. You have to install the ESP board in the IDE. Add in File->Properties->Additional Board Manager URLs: http://arduino.esp8266.com/stable/package_esp8266com_index.json
Select Board „…“ > Board Manager… , choose esp8266 and press install. After that you can program the ESP like any other Arduino. For programming the jumper has to be set on starting the board. Sometimes the upload fails with some strange error messages. If this happens I simply restart the ESP and try it again. Remember to remove the jumper after uploading the software. Wake-up from deep-sleep is not working when the jumper ist set.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
#include // WLAN Name und Password (PSK) const char* ssid = "SSID"; const char* password = "PSK"; WiFiClient client; // Server Adress of my raspberry char server[] = "10.0.0.3"; int port = 80; //If you use a different port on your webserver adjust the no here // Update Intervall const unsigned long postingInterval = 1800L * 1000000L; //DHT init #include #define DHTPIN 4 #define DHTTYPE DHT11 // DHT 11 DHT dht(DHTPIN, DHTTYPE,16); // needed to avoid link error on ram check extern "C" { #include "user_interface.h" } void setup() { // Pin 12 powers the sensors pinMode(12, OUTPUT); digitalWrite(12, HIGH); // Serial interface for debugging Serial.begin(115200); Serial.println("WLAN Logger - Electric Playground"); // start WIFI WiFi.mode(WIFI_STA); WiFiStart(); // waiting delay(3000); //DHT init dht.begin(); // ADC (Soil) init pinMode(A0, INPUT); } void loop() { // debug while (client.available()) { char c = client.read(); Serial.write(c); } // read sensor values float hum = dht.readHumidity(); float temp = dht.readTemperature(); float soil = analogRead(A0); //Debug Serial.println("Humidity:"+String(hum,2)+"\tTemperature:"+String(temp,2)+"\tSoil:"+String(soil,2)); //Send values httpRequest(hum,temp,soil); //power of sensors and go to deep sleep delay(500); digitalWrite(12, LOW); ESP.deepSleep(postingInterval, WAKE_NO_RFCAL); delay(1000); } //Transmit data to webserver void httpRequest(float h, float t, float s) { client.stop(); delay(100); //build URL String url = "/newrecord.php?"; url += "temp="; url += String(t,2); url += "&humidity="; url += String(h,2); url += "&soil="; url += String(s,2); // call URL if (client.connect(server, port)) { Serial.println("connecting..."); client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + server + "\r\n" + "Connection: close\r\n\r\n"); Serial.println("data submitted."); delay(10); } else { Serial.println("connection failed"); } } // Establish WIFI connection void WiFiStart() { Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.println(WiFi.localIP()); } |
One thought on “Irrigation- Part 1: A Prototype”