-
BEFORE WE START When you first connect the IoT-WiFi-board (hereinafter also: NanoESP-) the computer may not find the required driver for the USB-to-Serial converter automatically. In this case, download the driver from www.iot.fkainka.de/driver and install it manually. The Arduino- software will then permit you to set the port and the board Arduino Nano (CPU: Atmega328). The controller should then be ready to use. You also need to make some settings for working with the serial monitor.
-
can visit www.iot.fkainka.de for help. The page also contains a forum, new user projects and all programs presented here in the latest version. The learning package contains a pinboard on which you can pin the NanoESP as illustrated below. This leaves you the most space for experiments, while the WLAN module protrudes over the plug board at the rear. The Micro USB cable can then be plugged in as shown in the picture in the following section and will barely be in the way.
-
The most important pins and designations of the board The WLAN module is controlled with AT commands. For this, the Arduino part of the board is connected to the WLAN module via pins 11 and 12. A small circuit converts the 5-V-levels into compatible 3.3-V-levels. Pins 11 and 12 should not be used in your own projects for this reason. Further important hardware properties of the board are summarised in the following table.
-
COMPONENTS IN THE LEARNING PACKAGE Find an overview of the parts contained in the learning package below. 1 IoT-WiFi-board (NanoESP) 1 pinboard 1m circuit wire 2 button 1 9-V-clip 1 LED (red) 1 RGB-LED (4 connection legs) 1 resistor 10 kOhm (brown-black-orange) 1 resistor 1 kOhm (brown-black-red) 1 photo transistor (2 connection legs) 1 NTC 10 kOhm 1 Piezo speaker 1 potentiometer 10 kOhm with red dial switch GETTING TO KNOW THE MODULE This first chapter is about the general functions of the WLAN-modules.
-
1.1 | Basic AT commands For a first impression how to use the AT-commands, best just try them out. Therefore, this section will introduce you to some of the basic commands for the module. For this, open the program P01_SoftwareSerial in the Arduino-IDE. This is a very simple program that does nothing but pass on all data received via the serial hardware interface of the micro controller to the ESP controller via a self-defined software interface. The entire thing works in the opposite direction as well.
-
AT in the serial monitor and pressing [Enter]. The uploaded program passes on the command to the ESP module, which in turn answers AT and then OK. The next command that you can test is: AT+GMR This command outputs the current firmware and version number. The command AT+RST resets the module. You will see a few illegible characters on the terminal first, followed by ready, which says that the module is now ready. Another command is: ATE0 This permits deactivating the echo of the module.
-
First attempts with the AT-commands 1.1.2 | WLAN-commands The following WLAN-commands can be used to change the WLAN properties of the module. Some commands not only permit specification of a condition, but also requesting the current condition. This is done by entering a question mark after the command, e.g. AT+CWMODE? The returned value usually will be +CWMODE=2 followed by OK.
-
AT+CWMODE=? , the module will answer with the possible parameters for the command, in this case 1-3. CWMODE is a command that you can use to specify the WLAN-mode, by the way. There are therefore three operating modes that I will explain below. 1 AT+CWMODE=2 – the module as Access Point (AP-mode) In the delivery condition, the module is an Access Point. This means that you can directly connect to the module with a WLAN-capable device, such as a smartphone or a PC.
-
The module in station mode. The IP of the connected computer is highlighted. 2 AT+CWMODE=1 – the module in station mode The command AT+CWMODE=1 sets the module to station mode. This mode permits connecting to your WLANrouter. This will also connect the module to the Internet and give it a lot more options. You can first use the command AT+CWLAP to list all networks in range to check if your network is within reception range.
-
AT+CWJAP Similar to the CWSAP-command, this has important parameters, i.e. the name of the WLAN-network (also called the SSID) and the password, each again in quotation marks and separated by a comma. Connecting to a second module that is set with the data according to the previous section would look as follows: AT+CWJAP="MyNanoESP", "MyPassword" It may take a few seconds to establish the connection. Then OK should be returned.
-
The board connects to a second NanoESP. 3 AT+CWMODE=3 – dual mode The third possible mode for the WLAN setting is dual mode. As the name suggests, it permits operating the module in station and AP-mode. This means that devices can establish a direct WLAN connection to the module, or reach the module through the router as an interim station. It is a practical mode, e.g.
-
how the commands can be automatically operated via the controller. You will also learn another command that you can use to test if a computer in the network or a server online can be reached. In this example, the Google server will be pinged. The example program P02_GooglePing mostly automates the processes that you entered manually in the first example. The controller sends commands to the ESP module in sequence, thus connecting to the WLAN, among others.
-
001 //-------Controll ESP-------002 003 boolean sendCom(String command, char respond[]) 004 { 005 esp8266.println(command); 006 if (esp8266.findUntil(respond, "ERROR")) 007 { 008 return true; 009 } 010 else 011 { 012 debug("ESP SEND ERROR: " + command); 013 return false; 014 } 015 } When you call the function, you therefore need to submit the command and the expected return value to the function, e.g. AT and the expected return value OK.
-
004 return esp8266.readString(); 005 } 2 Troubleshooting There will often be errors and complication when developing programs. To have any chance at all at finding them, there are two debug-functions that are activated or deactivated via a parameter at the very beginning of the program. #define DEBUG true The first function does nothing but provide a simplified output of text via the serial interface defined as standard. When the constant DEBUG is true, the content of the string Msg will be sent.
-
006 Serial.write(esp8266.read()); 007 if (Serial.available()) 008 009 esp8266.write(Serial.read()); } 010 } 3 Configuration To improve overview of the programs in general, most settings have also been removed into individual functions, first of all the function espConfig, in which the most important parameters for the respective program are set. 001 //---Config ESP8266--002 boolean espConfig() 003 { 004 boolean success = true; 005 esp8266.
-
019 020 success &= sendCom("AT+CIPMODE=0", "OK"); 021 success &= sendCom("AT+CIPMUX=0", "OK"); 022 023 return success; 024 } At the beginning of the function, the variable success is set to true first, since this variable is now and-linked to various functions. This means that even if only one of the functions that have the value returns false, success will also immediately become false and the entire configuration will have failed.
-
008 return success; 009 } The function configStation() has been called in the espConfig()-function. Here, setting of the WLAN-mode to station mode with the command CWMODE and then connection to the network via the CWJAP-command are performed. It can take quite a long time until the connection is established. Therefore, the time-out is briefly raised to 20 seconds here. If you prefer dual WLAN-mode, you can set CWMODE to 3 here.
-
005 // set the data rate for the SoftwareSerial port 006 esp8266.begin(19200); 007 008 if (!espConfig()) serialDebug(); 009 else debug("Config OK"); 010 011 if (sendCom("AT+PING=\"www.google.de\"", "OK")) 012 { 013 Serial.println("Ping OK"); 014 digitalWrite(13, HIGH); 015 } 016 else 017 { 018 019 Serial.
-
the board will also light up after successful configuration. This also gives you feedback when the module is not connected to a PC with serial monitor. In this experiment, however, the LED is needed for the feedback of the ping status. The query takes place right in the next line of the configuration, too. The AT+PING-command will be sent with the Google address as a parameter. You can query an IP address from your local network instead of this address as well.
-
The source text for this project differs from the previous experiment mostly in the following functions: 001 void findSSID() 002 { 003 004 005 esp8266.println("AT+CWLAP"); if (esp8266.
-
will then scan for all networks in the environment. When the network you are looking for has been found, the function alarm() will be tripped, which switches on the LED D3 and emits a signal sound at the piezo. In the example program, we scan for a network with the SSID NanoESP, i.e. actually other NanoESP-networks in range. You can also enter another SSID in #define ToFindSSID at the beginning of the program. Then you can check, for example, how far your WLAN-network goes.
-
What is a port? When comparing to a postal address, the port would be similar to the front door in an apartment house. A computer with a unique IP can provide different services via different ports. You can reach the server via the IP, but you use the port to choose the service to be used. For example, this can be port 20 for FTP data transmission or port 23 for a Telnet connection. You can usually select the port freely; however, there are standardised ports that make handling web applications easier.
-
is configured as an access point and you can see an open network called NanoESP NanoESP. Before connecting to the network, first download a program from the Internet. In my experiments, I used the program Packet Sender by Dan Nagle which you can download from the following link: https://packetsender.com/ After loading and installing the program, you can connect your PC to the open network of the NanoESP. Ensure that the firewall recognises the network as a home network, to avoid blocking data.
-
set as UDP client. The differentiation between client and server is not clear in the UDP protocol, but in this case it means that you will send data from your controller to the computer. The message has been successfully transmitted. To send data, use the command: AT+CIPSEND=7 The 7 means the number of characters to be sent. The character > is returned. This means that you can now send your message. Enter Hello and confirm with [Enter] again.
-
The message has been received by Packet Sender. 001 boolean configUDP() 002 { 003 boolean success = true; 004 005 success &= (sendCom("AT+CIPMODE=0", "OK")); 006 success &= (sendCom("AT+CIPMUX=0", "OK")); 007 008 success &= sendCom("AT+CIPSTART=\"UDP\",\"192.168.4.
-
009 } In the Arduino program, the function configUDP() is particularly decisive for the communication path. The settings important for transmission are made there. First, use CIPMODE to set the data transparency mode to 0. Finally, use CIPMUX=0 to set that only one single connection is permitted. The decisive command is CIPSTART. It is used to establish a commutation, specifically to IP 192.168.4.2, i.e. to your PC, and to PORT 90, where the program Packet Sender is listening with its UDP-server.
-
The Packet Sender has successfully submitted »Hi«. The message has been received. You can answer by using the CIPSEND command again, i.e. for example: 001 AT+CIPSEND=7 002 >Hello The difference from the previous program is only in a single line: success &= sendCom("AT+CIPSTART=\"UDP\",\"192.168.4.2 \",90,91", "OK"); As you can see, a second port was indicated. This port, here the one with number 91, is the port through which the module listens for incoming data in turn.
-
ing this simple line, you can also send data to the module. You can also listen at the same port to which you are sending. You can therefore also enter 90 for both ports. Theoretically, the change also permits the module to receive its own data. 2.3 | Switching an LED by UDP The program P06_UDPLED.ino now finally is about controlling hardware with the UDP. In this program, an LED can be switched on and off with simple commands.
-
LED on and off accordingly. Feedback to the transmitter is transmitted as well. If another command is sent, the serial monitor reports "Wrong UDP Command". The same message is also submitted to the transmitter via the network. In the source code, we will first look at a line in the function configUDP() again: success &= sendCom("AT+CIPSTART=\"UDP\",\"192.168.4,255 \",90,91", "OK"); The IP has changed now. This IP should look strange to you, since it is not the IP of your computer.
-
018 debug("Wrong UDP Command"); 019 if (sendCom("AT+CIPSEND=19", ">")) 020 { 021 sendCom("Wrong UDP Command", "OK"); 022 } 023 024 } 025 026 } } 027 } The inbound commands are analysed in the loop-routine, which is continually gone through. Once data from the module arrived (esp8266.available()), they are analysed for the presence of the characters »+IPD,«. If the command led is also found, the command parseInt() automatically saves the next number in the variables setLed.
-
The switch, connected space-savingly to D8 The program The program continues to evaluate the incoming commands. Additionally, however, the button is continually queried. When the user actuates it, the controller sends the text Button=1 to the network. All devices connected to the module with a UDP server on port 90 can receive the command. You can check this again with the Packet Sender.
-
The process in the Packet Sender The changes to the program are mostly in the loop-routine. A simple if-query checks if the switch is pushed. If this is the case, the controller will submit the message Button=1 to the network. Additionally, there will be a debug-message. The following while-loop prevents an entire flood of commands from being sent at once while you push the switch. You need to release the button before the program continues.
-
For a building automation project, a server would receive the status message, e.g. of a motion sensor, and then send the command to activate the light to another controller. This way, an entire network of sensors and actors can be set up. 2.5 | Analogue sensor In the last project, a button was used to deal with the simplest form of a sensor. This time, a potentiometer should be used as an analogue sensor to permanently send measured values into the network.
-
the board later. Communication with the board works similarly to the previous experiments. Only the IP of the module and your computer will have changed, since both devices now have had an IP assigned by the router. Packet Sender receives no measurements at first after the start. First, you need to send a message, e.g., the command led=1, to the module. For this, enter the new IP of the module in the Packet Sender, which you can find via the serial monitor.
-
192.168.255.255\",90,91,2", "OK"); There are the following options for this parameter: 1 mode 0: This means that the IP and port will not change. This is also the default setting, which becomes clear when you look at the other modes. 2 mode 1: The settings change once. This means: When the module starts with the currently used broadcast address and then receives something from a PC, the module will switch to the new address of the PC.
-
mission takes some time. However, the frequency at which new data are transmitted is so high that the PC will be bombarded with messages. TCP CLIENT The last chapter was about the UDP, which can be used to send and receive data easily. The protocol already permits implementing a large number of applications. In this chapter, we will deal with the TCP (Transmission Control Protocol). The module will take the role of the TCP client in this chapter.
-
This command establishes a TCP connection to the website www.example.com. Port 80 is the standard port for HTTP-queries. After confirmation of the connection with OK you can enter the next command, which you already know: AT+CIPSEND=40 You want to send a message through the connection you have just established, after all. When you are asked to enter a text with >, first enter GET / HTTP/1.1 and then push [Enter]. [Enter] will not appear on the serial monitor, but the module will have received it.
-
difficult to remember. When the client is connected, the browser will send a GetRequest query. This query at least needs to contain the requested page or resource (in this case the main page), the protocol used (http 1.1) and the requested host (www.example.com). Entering the host is important, since several web addresses may be located on the same server and thus behind the same IP. If you want to request another page than the home page, replace / e.g. with /example.html.
-
002 { 003 004 boolean success = true; int xyear, xmonth, xday, xhour, xminute, xsecond; //local variables 005 006 success &= sendCom("AT+CIPSTART=\"TCP\",\"" + Host + "\",80", "OK"); 007 String getRequest = "GET " + Subpage + " HTTP/1.1\r\nHost:" + Host + "\r\n"; 008 success &= sendCom("AT+CIPSEND=" + String(getRequest.length() + 2), ">"); 009 010 esp8266.println(getRequest); 011 012 if (esp8266.find("+IPD")) 013 { 014 if (esp8266.find("\r\n\r\n")) 015 { 016 xyear = esp8266.
-
025 026 027 setTime(xhour, xminute, xsecond, xday, xmonth, xyear); 028 sendCom("AT+CIPCLOSE", "OK"); 029 return true; 030 } 031 else return false; 032 } 033 else return false; 034 } Parameters for the host address and the subaddress are submitted to this function. The Get-Request query is created from this and submitted to the TCP server of the website after a connection is established. The server response now needs to be analysed.
-
mits presenting almost any colour. The LED should be connected to the PWM outputs D3, D5, D6 of the controller with dropping resistors. Connection of the RGB-LED to pins D3, D5 and D6 The program The sketch again is about calling a website; this time, it is a page specifically programmed for this project that collects data from the weather page http://www.openweathermap.com/ . On this page, you can get information on the weather in your town by varying the URL.
-
003 int green, blue, red ; 004 005 006 007 if (val <= 10 & val >= -20) blue = map(val, -20, 10, 255, 0); else blue = 0; 008 009 010 if (val >= 10 & val <= 40) green = map(val, 10, 40, 255, 0); 011 else if (val >= -20 & val < 10) green = map(val, -20, 10, 0, 255); 012 else green = 0; 013 014 if (val > 10 & val <= 40) red = map(val, 10, 40, 0, 255); 015 else red = 0; 016 017 analogWrite(RED, red); 018 analogWrite(GREEN, green); 019 analogWrite(BLUE, blue); 020 } Adjustment of the LED brig
-
After the last chapter explained a bit about use of the module as a TCP client, the module is now to act as a dedicated TCP server. Practically, there is a simple AT command for this with which you can start this complex server application. The module will then act as a TCP server from the internet, except that you need to program sending of the website yourself. 4.1 | TCP web server The first attempts at a TCP web server are made without any additional hardware setup.
-
The browserquery The browser now waits for a response, and will show a loading sign until then, or until the connection is interrupted due to time-out. You can send a message to the browser with a version of a familiar command: AT+CIPSEND=0.7 The parameter 0 indicates the client to which the message is to be sent here. This is necessary because multiple connections are permitted and several clients may therefore also be connected. The second parameter, here 7, again indicates the characters to be sent.
-
permits control of an LED. The setup picture also shows how to connect an external power supply to the board. As an alternative to this kind of power supply, you can also use a power bank (an external rechargeable battery, noESP, 1 x 9-V-clip, 1 x LED (red), 1 usually for Smartphones), which can supply the brown-black-red), circuit wire, 1 x 9-Vboard easily via the micro-USB connection. d in the learning package) How to connect the battery to the test setup.
-
004 if (esp8266.find("+IPD,")) 005 { 006 debug("Incoming Request"); 007 int connectionId = esp8266.parseInt(); 008 009 if (esp8266.findUntil("LED","\n")) digitalWrite(LED, !digitalRead(LED)); 010 011 String webpage = "
Hello World!
Open [IP]/LED to Toggle LED on D9"; 012 013 if (sendCom("AT+CIPSEND=" + String(connectionId) + "," + String(webpage.
-
of type 1. This is not proper HTML code yet, but only a simple form of text formatting. The length of the website is handed over with webpage.length() (a stringclass function) to the CIPSEND-command and the page is finally transmitted. 4.3 | Website with buttons In this experiment, the illustration of the website is even more sophisticated. There are now also control elements that permit much more comfortable control of the LED.
-
002 "
\n
-
005 if (sendCom("AT+CIPSEND=" + String(connectionId) + "," + String(webpage.length()), ">")) 006 { 007 esp8266.print(webpage); 008 esp8266.find("SEND OK"); 009 success &= sendCom("AT+CIPCLOSE=" + String(connectionId), "OK"); 010 } 011 else 012 { 013 success = false; 014 } 015 return success; 016 } The loop-routine now waits for a request query.
-
but improves presentation on mobile devices (
002 003 004 Switch LED 005 006 After the HEAD, you need the BODY. It contains the content of the website. In the starting area of the BODY, additional parameters such as the background and font colours are specified.
-
All elements presented so far were pure form factors that are used to design the website. Next will be the important form-element to switch an LED. 001
The form-element is, as the name suggests, meant to create forms online. These may be registration forms for a website or surveys or similar things.
-
you like. You can, for example, change the background colour or add more text to the website. However, do not overload the website. The SRAM will reach the end of its capacity quickly. When you have completed the changes, it is time to transfer it to your Arduino program. For this, copy the entire text into the clipboard and go to the website with the Swiss Converter Tool: http://www.percederberg.net/tools/text_converter.
-
noESP, 1 x RGB-LED, 3 x resistor ck-red), circuit wire site has been adjusted and should be easy to display even on Smartphones. The required setup is shown in the lower figure. Connection of the RGB-LED to pins D3, D5 and D6 The program The new transmitted website is again placed in the Progmem variable site. Again, you can view the HTML page in the Sketch folder. After setting the WLAN data and uploading the program, the website of the web server can be reached via the IP of the module.
-
The website in your browser Selection of the colour in the Chrome browser Even if the design of this website does not differ greatly from the previous one, there are some elements that I would like to describe in more detail.
-
This line is meant to stop the browser from trying to load the Favicon after loading the website. Usually, a website has another special icon that differs it from other websites and clearly identifies the website in a browser bar with several tabs. For the browser to load this character, it will send a second request query after calling the page and ask for this Favicon. You may have noticed this additional Request query in your first experiments with the TCP server.
-
The chosen colour is now transmitted in the form /?rgb=%23, followed by six more characters. The expression %23 suggests that this is a hexadecimal digit. For the colour white, the URL therefore is: [IP]/?rgb=%23ffffff The controller now needs to extract the individual colour values of the LED from this HEX number, which is done in the following part of the loop-function: 001 if (esp8266.findUntil("?rgb=", "\n")) 002 { 003 String hexstring = esp8266.
-
sensor. The photo transistor can easily be mistaken for an LED. You can recognise the photo transistor by looking onto the head of the part from above. The photo transistor has a large black area inside. The following figure shows how the experiment is set up. The collector of the photo transistor is the shorter connection. It is connected to +5 V. The resistor in series with the photo transistor has 10 kOhm.
-
The website of the brightness sensor For the system to work, the HTML files have a few small changes again. The first change is about in the header area: This small line ensures that the browser automatically re-loads the website every three seconds. This way, you do not have to push [F5], all the time to view new values.
-
003 String xBuffer; 004 005 for (int i = 0; i <= sizeof(site); i++) 006 { 007 char myChar = pgm_read_byte_near(site + i); 008 xBuffer += myChar; 009 } 010 011 xBuffer.replace("*bright*", String(analogRead(SENSOR))); 012 013 return xBuffer; 014 } The placeholder is replaced in the function createWebsite(). First, the Progmem variable is loaded from the memory as usual and saved in a string.
-
Connection of the LEDs to D2-D7 Attention! LEDs must not be connected without dropping resistors. In this case it is permitted due to the On resistors of the internal port FETs of approx. 30 Ohm. Because the LEDs are placed between two ports, they actually work with a dropping resistor of 60 Ohm. Depending on LED type and colour, an LED current between 15 mA and 30 mA at most occurs. This is still permitted. The program The website of this program uses check boxes as HTML elements.
-
The website GPIO control This HTML code uses the website as input form and output element alike. If you look at the form element, you can see that a number of input elements of type checkbox are used. They are assigned an individual name that is derived from the pin name. The placeholder in the text is the text *checkedX* in each case. When the pin is low, the placeholder is simply deleted.
-
Evaluation in the program works as follows now: Let us assume that boxes 3, 5 and 7 have been selected in the form. The URL changes to: [IP]/?ld3=on&ld5=on&ld7=on This means that only selected boxes will be submitted and can be identified based on the index. This is done in the loop-routine. First, the entire port D on which the digital outputs are pending is switched to low. Then a while-loop will scan for all »ld«s in the resource link.
-
002 { 003 String xBuffer; 004 005 for (int i = 0; i <= sizeof(site); i++) 006 { 007 char myChar = pgm_read_byte_near(site + i); 008 xBuffer += myChar; 009 } 010 011 for (int x = 2; x <= 7; x++) 012 { 013 if (PORTD & (1 << x)) 014 { 015 xBuffer.replace("*checked" + String(x) + "*", "checked"); 016 } 017 else 018 { 019 xBuffer.replace("*checked" + String(x) + "*", ""); 020 } 021 } 022 return xBuffer; 023 } I had some problems when creating this program.
-
on the SRAM is mostly in the generous use of the practical but also resourceconsuming use of the String functions and generally the use of strings instead of char-chains. A string.replace() is very practical, but it does eat up memory. If you encounter inexplicable errors at some point, I recommend reducing the source code of the HTML file and also possibly optimising some String operations. The above Library can help you in troubleshooting. 4.
-
The proper settings in the Fritz!Box The settings int he router are clear now, and you can try your first experiment. For this, you need the IP, but now not the one of the board's IP in your local network, but your global IP. You can find it out on the page http://www.meine-aktuelle-ip.de/ again. If you enter the IP determined there in your browser now, you should see the website of the module. However, this time it is done taking the long path through the internet.
-
The website AnyDns.info First, you need to log on to the website and enter a domain name. I have chosen the name nanoesp and the host dynpc.net. After login, this creates the data: http://nanoesp.dynpc.net/ Now the service needs to learn your IP. Enter the service in your router, so that a new IP will be sent directly to the DDNS service. In the Fritz!Box, I first had to click Ansicht: Erweitert at the bottom to display all options. Then I could enter the DDNS service under Freigaben.
-
The settings in the Fritz!Box for using Dynamic DNS A word of warning: The dynamic DNS service is very practical, but you should be careful about who you tell the domain name. You make yourself vulnerable to attack. A hacker only needs to know your domain now, rather than your current IP address, to attack your router. Therefore, I will also leave the above page online only for test purposes. THINGSPEAK This last chapter will treat an entirely new subject: the ThingSpeak platform.
-
5.1 | ThingSpeak Before you tackle the setup and program as usual, you first need to set up an account on the website www.ThingSpeak.com . Log in with your user data under the item Sign In. You can see a website that shows your channels. Since you have no channels yet, this site will look rather empty. Click New Channel and assign a name, e.g. Light.In this project, you will measure brightness. In the item Field 1 you can now assign a name to the field, e.g. Brightness.
-
Creating the channel on the ThingSpeak page Click Save Channel to save your settings.. You will be forwarded to the page of your channel, on which you will only see an empty chart. Click API Keys in the tab above. The sequence of numbers and letters that you will find in the item Write API Key will be needed in a moment.
-
The setup of this experiment is made up of a sensor at the analogue input A6. A voltage divider with 10-kΩ-resistor and photo transistor permits measuring the current brightness. You can also use the temperature sensor, however. The circuit remains nearly the same, but the light transistor is replaced by the black NTC. The polarity in the noESP, 1 x photo transistor, 1 x reNTC does not matter.
-
The measured results in the chart The source text seems to differ a lot from all previous programs. However, it is essentially composed of known elements. A Progmem variable contains the HTTP request that must be sent to the ThingSpeak-page, as well as some placeholders that need to be replaced as necessary. 001 POST *URL* HTTP/1.1 002 Host: api.thingspeak.
-
/update. This is the sub-page to which the data must be sent. The message is now made up of your API key, the field to be filled and the value. The length of the message can be determined easily by the length of the strings. As a whole, an example POST looks like this: 001 POST /update HTTP/1.1 002 Host: api.thingspeak.
-
The experiment setup with an LED at pin D9 The program In addition to the hardware setup, some steps on the ThingSpeakpage are necessary. When you click Apps in the top-most menu of the website, you will be shown a number of different application options. This time, we will deal with the app ThingHTTP. If you click the corresponding button, you will first be shown a rather empty interface. Click New ThingHTTP. Enter the following into the form that comes up: Name: Twitch URL: https://api.twitch.
-
ested in the attribute _total, which displays the number of active streams. If the number is larger than zero, at least one stream is active. This attribute is now automatically parsed by the ThingSpeak-page (analysed) and output as a betterstructured value. This value can be called and assessed easily in the program by the function getThingSpeakHttp(). 5.3 | Twitter alarm system This project is an alarm system with which you can, for example, check whether someone opens a drawer without permission.
-
Click Apps and then ThingTweet. By clicking Link TwitterAccount and entering your access data, you will connect the two services. If you have no Twitter account yet, it will pay off to create a test account for working with the learning package. After Twitter has been successfully linked to ThingSpeak you can enter the API key under Apps/ThingTweet after the item #define TwitterKEY in in this program. The program now continually reviews whether the measured brightness increases over 500.
-
Setup with two switches at D5 and D10 and an LED at D9 The program First, you need to create a new TalkBack channel under Apps/TalkBack. You can use, e.g., Doors as the name. If you like, you can also have the commands entered in a channel. This can be the already-created light channel from the first ThingSpeakexperiment, or a dedicated channel. All commands are then logged. Particularly the API key, which you will enter in #define TalkBackKEY.
-
The TalkBack overview when entering a command There is also an option with which you can enter commands directly via the internet. If you click your Doors channel on the TalkBack-page, you can see the option Add a new command below. You can use it to enter the command OpenDoor or CloseDoor manually and thus control the module. You can therefore also control the board from different sources via TalkBack-commands. In the source text, the function getTalkBackCom() will query new commands.
-
5.5 | Cheerlights Today's experiment is based on a project by Hans Scharler that is called Cheerlights. The idea: Globally linked lights that can be simultaneously controlled via Twitter commands. It is a good example of the world growing closer and closer together with the noESP, 1 x RGB-LED, 3 x resistor Internet. ck-red), circuit wire The RGB-LED on the pinboard at pins D3, D5 and D6 The program For today's program, you do not need to make any dedicated ThingSpeakchanges.
-
The Cheerlightspage with the current colour purpose The program also needs the Crossfade-Library by Radek Wierzbicki (source: https://github.com/radekw/Arduino/tree/5f24ce7c8db9dfbb5252b59824c3217d851 b3a3c). For practical reasons, a copy of the Library version used is enclosed in the sketch folder. It must be copied into the libraries folder of your sketchbook folder.
-
A possible tweet may look like this: Testing my #cheerlights project on my #NanoESP with the color blue #ThingSpeak #IoT This way, you can recolour the world. The query for the current colour is implemented in the function getCheerlightColor() . The parameters needed are the host, i.e. api.thingssspeak.com, and the URL, in this case /channels/1417/field/1/last.txt. This is a simple TCP client query of the known kind. Again, the server response is shortened again to the relevant text and returned.
-
The setup of the fire alarm project The program The program must combine several levels. The ThingSpeak-page is very important again. Among others, the threshold monitoring of the NTC is assumed by a ThingSpeak-app. From there, the alarm action is performed, i.e. sending a Twitter message and inserting a TalkBack-command that trips the alarm on the controller. In the first step, you need to set a new channel on the ThingSpeak-page. You can name it FireAlarm, for example.
-
Generally, this would be a full project already. However, the bonus functions are still missing. They no longer need to be performed in the program, however, but only on the ThingSpeakpage. For this, go to Apps and then select React. React can be used to react to specific events.
-
ate another React element which contains the same parameters as the first one, but with the change that you will select ThingHTTP under Action and there the item Alarm. Thus, you have ensured that an alarm sounds when the critical value is exceeded. You can also have the alarm output time-controlled. For this, go to Apps and then click TimeControl and create a new element, e.g. with the name AlarmClock.
-
The right TalkBack settings for the fire alarm For a first test, it is recommended to select a time in a few minutes. If this has worked, you can set the proper time. It is surely not the most beautiful sound to be woken up by, but it is a particularly effective one.
-
AT commands Command Writing Basics Test command AT Reset AT+RST Firmware information AT+GMR Echo on/off ATE<1/0> WLAN-commands WLAN-mode (1 = Client, 2 = AP, 3 = Dual) AT+CWMODE= Finding WLAN networks AT+CWLAP Connecting WLAN AT+CWJAP=««,«« Disconnecting WLAN AT+CWQAP WLAN-Access-Point settings AT+CWSAP=««,««[,,] Output IP-address AT+CIFSR Activate/deactivate DHCP AT+CWDHCP=<1/0> Automatically connect to WLAN AT+CWAUTOCONN=<1/0> Changing M
-
Setting IP-address (Access Point) AT+CIPAP= Start SmartConfig AT+CWSTARTSMART= Stop SmartConfig AT+CWSTOPSMART Communication Function ping AT+PING= Permit several connections AT+CIPMUX= Data mode (0=Transparent, 1=Data mode) AT+CIPMODE= Structure of data received +IPD,,: Establishing connection AT+CIPSTART=««,««, Send data AT+CIPSEND=, Disconnect AT+CIPCLOSE= Server-commands Start server AT+CIPSERVER=1,
-
Pinout