Sunday, November 20, 2016

ESP8266 adapter module fits LoRa Dorji module

Soldering the Dorji LoRa module is not so easy if you don't have soldering skills. But you can borrow this adapter board ($2.60 per 10pcs) from ESP8266 and its fits very well. Same pads distance, just few modification ( remove components) and a short on the back where the AMS1117 should be and that's it, we have a more practical module to work with. Don't forget to add a curly antenna.

Don't forget to relabel the edges with the Dorji's module values, since the labels will not be visible anymore.



Dorji's LoRa module on ESP8266 adapter plate

ESP8266 adapter plate
Back of ESP8266 adapter plate 

Monday, November 14, 2016

ESP8266-ESP201 Step-by-step Guide




This is a step-by-step guide to ESP8266-ESP201.

1.       Buy ESP8266-ESP201 with its hardware development kit from eBay, click here:



The development board is shown in photo below as well. You have a relay, buzzer, switches, LEDs, etc. to play with and test your code and to learn input/output functions of ESP8266:



2.       Connect the USB cable between your computer and the development board.
3.       Push the power button to check if power led is working and the board shows sign of life.
4.       Complete schematic of the development board is as follows:



5.       On the PCB near the DIP switch these are the values:
·         R - should be the RED led from the RGB connected to the IO15 pin. Putting the R DIP to ON will light RED if the GPIO15 is HIGH.
·         G - GREEN led from RGB led is connected to IO13. Putting the G DIP to ON will light GREEN if the GPIO13 is HIGH.
·         B - BLUE led from RGB led is connected to IO12. Putting the B DIP to ON will light BLUE if the GPIO12 is HIGH.
·         W - WHITE led located almost under RGB led is connected to the IO14 pin. Putting HIGH on GPIO14 and DIP switch ON will light the WHITE led.
·         J - relay pin connected to IO16 (which is always HIGH - I have no idea why. This behavior and the RED led that is not working can be because I have a bad board or the design for all the boards is wrong. Connecting the IO16 to GND (not recommended) will stop the relay, otherwise it will be ON all the time the J DIP pin is ON.
·         B - BUZZER connected to IO5 pin through B DIP switch. Having GPIO5 HIGH and B on DIP switch ON will prove that the buzzer is working.
·         K1 - I assume is connected to S2.
·         K2 - I assume is connected to S3.



6.       A schematic on a napkin will look like this one:



7.       ESP8266 comes with pre-installed AT commands, so you can check these to see if you get any response. The list of AT commands can be found here:



To test the AT commands, you need to have a program like “Hyper Terminal”. The easiest and recommended way is to install Arduino from here which has a built-in serial monitor through which you can send and receive data.



Once you have downloaded and installed Arduino, you can now run it and it will look like this:



Now click File menu and then select Preferences. It will look like this:



Now add the link below in the “Additional Boards Manager URLs” because ESP8266 board is not included in Arduino by default.


Click OK button.

Now click Tools menu and select Board. Our board in this case will Generic ESP8266 Module. Your screen should look like this:



Now click Tools menu again and select Port from the list of available ports. Your screen should look like this:



Now if you have set everything corrected (i.e. (a) USB connection between ESP8266 development board and computer, (b) Settings in Arduino software) then you are ready to type AT and send AT commands to your ESP8266 and be excited to see “OK” response from your chip. When you send AT to your ESP8266, it will respond you with OK.

Click Tools menu and select Serial Monitor or press on your keyboard Ctrl+Shift+M to open serial monitor where you can send and receive AT commands from serial interface. Make sure you select (a) “both NL and CR” for both new line and carriage return, (b) correct baud rate (e.g. 115200 baud). Your screen should look like this when you ready to send AT commands:




8.       If you have been successful so far, you can be sure that your ESP8266 and its development board and communication between your computer and development board – all is working fine!
9.       Now you want to know how to control GPIO pins by yourself. For that, click File menu, select Examples, select ESP8266WiFi, and then select WiFi WebServer. Your screen should look like this:

                


A new window with WiFi webserver example will open (as shown above in left screenshot). Now edit this file by typing in your WiFi SSID and password. Save the example with another filename and then press upload button to start code compilation and upload to the ESP8266. This will fail. To be successful you need to perform a few more steps.

10.   Turn the board off; Ground the IO0 pin; Set K2 to Ground (ON); Power on the board; and Set K2 to OFF.
11.   Now press Ctrl+Shift+M to open Serial Monitor and then click upload button again, if it fails or shows error close Arduino and open Arduino again and press upload button. It will upload successfully – at least it did it for me! J
12.   Now you will see in Serial Monitor window that your ESP8266 is now connected to your WiFi network and shows an IP address from where you can control IO2 to be 1 or 0.
13.   Connect LED to IO2 and Ground. Go to the given IP address in Serial Monitor (say, 192.168.0.140) and turn on/off LED like this:

14.    The pinouts of ESP8266-ESP201 look like this:


Helpful resources:

·         http://www.esp8266.com/


s

Guest post by: Ahmed Hussain

Friday, November 11, 2016

LoRa Gateway has new antenna

Finally the new 7dB antenna arrived. Since the new antenna has a 3cm magnetic mount I will try to put it on top of the car for better coverage.

New 868Mhz 7dB LoRa antenna


Specs:

Antenna gain: 7dB
Magnetic mount: 3cm
Cable length: 150 cm
Connector: SMA male

I can connected it to the gateway or to the ESP8266 Lora module from Dorji.com.



Wednesday, November 9, 2016

ESP32 - How to increase the maximum number of sockets

Still didn't found an ESP32 with a decent delivery price so today I've tested the environment provided by EspressIf looking on the maximum number of sockets. On ESP8266 I've managed to have more then 20 sockets opened and carrying MQTT packets ( see https://myesp8266.blogspot.co.uk/2016/11/mqtt-broker-on-esp8266-5.html)

I've noticed that the maximum number of sockets that you can setup from make menuconfig is 16. 

All the values that you are setting from make menuconfig are ending in a file named sdkconfig in the root of you app directory. This sdkconfig file will be converted to sdkconfig.h located in app/build/include/sdkconfig.h.

Even you are modifying a value direct in the sdkconfig on the compile time you will be invited to enter a value 1..16 for maximum number of sockets.

Solution #1. (Safest one)

Change the sdkconfig.h file overwrite the desired value and recompile

#define CONFIG_LWIP_MAX_SOCKETS 20

Solution #2. (not recommended but possible )

Modify directly the file:

esp-idf/components/lwip/include/lwip/port/lwipopts.h
#define MEMP_NUM_NETCONN          20 //CONFIG_LWIP_MAX_SOCKETS


If you modified values in make menuconfig and you don't know what was before don't worry just do a diff between the app/sdkconfig and app/sdkconfig.old file.


Obs: this post can be found also on this link.



Sunday, November 6, 2016

Mqtt broker on ESP8266 #5

[Later edit]. On iotcentral.eu you will find instructions on how to install the ESP8266 MQTT broker on your EPS8266 and how to use the MQTT service provided by iotcentral.eu

I've accepted Anthony's challenge to squeeze more from the ESP8266 as MQTT broker so I managed to increase the maximum number of simultaneous subscribers on a single ESP8266. 

Now instead of 9 like I had before ( plus bridge to/from cloud and websockets to connect my mobile app to ESP8266 MQTT broker) I have 20 stable subscribers.

Top was 30 but the heap memory was too low to have flawless connections to all subscribers.

Also a good news is that this is not limiting the number of topics a device can subscribe to the broker ( in a reasonable number of 4 or 5 topics per device).

A picture with 25 connections and one with websocket.



ESP8266 as MQTTbroker 

At the beginning I have 35Kb and after 25+1+1 connections I am ending with 11 to 12 Kb of heap memory which is plenty even for bigger payloads.


Related links:
Mqtt broker on ESP8266 #4
Mqtt broker on ESP8266 #3
Mqtt broker on ESP8266 #2
Mqtt broker on ESP8266 #1