Sodaq Mbili and wifibee

Hello,

I am the happy owner (but still a very beginner) of the SODAQ MBILI board.

I also managed to create some small tools using for example a temperature sensor that
connected via a grove connector to the board.

Last week,I bought a wifi bee (ESP8266MOD AI-THINKER) from you guys, which I received a
few days ago.

but now I don’t know how to use it. How can i verify that the module is working. What is the mac-adress and the initial password of the wifibee? Can it get changed

I have looked on the internet but did not find anything that corresponds to my wifibee
module, and the examples I tried do not run.

Do you have some examples available; so that i can get started? Where can i find the libraries that I need for this

the aim of my project is to grab the temperature from the groove sensor and send it via
the wifi module to some webpage. I guess this also involves connecting to my wifi router?

thanks in advance,
Chris

1 Like

I forgot to say that the wifibee also has a switch. the choices are RUN or PROG. What option to choose when.
some background information on the possibilities would be nice…
thanks
Chris

Have a look at this library

https://github.com/GabrielNotman/Sodaq_WifiBee
1 Like

Hello,

I downloaded the library and opened one of the samples.
i changed the SSID and PASSWORD, but when i run the sample, i get the following messages from the system

NodeMCU 0.9.5 build 20150318 powered by Lua 5.1.4
lua: cannot open init.lua

What does that mean? is there something wrong with my wifiBee?

What I also find strange, is that when i look for wireless networks on my laptop, is that there is no wifiBee network…
Or is that normal?

Regards,
Chris

The NodeMCU has the ability to execute a script (init.lua) on startup, this is optional.

The message you are seeing is not an error, but just a notification that it did not execute the startup script as it does not exist.

Hello,

but why can’t I see the wifibee as one of the networks on my laptop?
Is there any possibilities to RESET the wifibee? How
I don’t know what else to test, because even with the provided examples; it doesn’t seem to work…
Also the switch RUN/PROG on the wifibee board is not clear to me? What status should I choose when and why?

Some basic documentation that describes the possibilities would be nice.

thanks
Chris

Hi,

The Sodaq_WifiBee library supports a range of functionality in station mode (where the device connects to an existing Wifi network), it does not support Access Point mode (where the device creates a new Wifi network for other devices to connect to).

There are a range of examples available with the library.

Full documentation on the available Lua API can be found here:
http://www.nodemcu.com/docs/index/

In order to test other Lua functionality, you will want to create a serial pass through sketch which copies all data between Serial and Serial1. This will allow you to type in the commands to the serial monitor, and see the responses.

Switching: The WifiBee uses the BEEDTR pin as a switch. Logic LOW switches the device on, and logic HIGH is off. This is normally handled by the library, but if you are creating a pass through sketch you will need to set this manually.

The RUN/PROG switch should be left in the RUN position. The PROG position is for updating the NodeMCU firmware (you will rarely, if ever, have to do this).

hi

I am new to SODAQ WIFI …
How do I send data to my own website using SODAQ WIFI ?

The URL which I have, except arguments like below:

http:/www.sitename.com?arg=1

Should I be using GET ?
Please throw some light on catching values and routing to a website.
I am stuck with this one …
Many thanks,
Barani !

? wifiBee.HTTPGet(“httpbin.org”, 80, “/get”, “iotdata”, code);

The HTTPGet method has the following definition:

bool HTTPGet(const String& server, const uint16_t port, const String& URI, 
    const String& headers, uint16_t& httpCode);

So in your case you would want to use something like this:

wifiBee.HTTPGet("www.sitename.com", 80, "/?arg=1", "", code);

The response code from that request will be written into the parameter code.

Hi Gabriel,

Thanks for your input.

I am using following code:
#include <Sodaq_WifiBee.h>

  ----- in the middle of the code ----

  wifiBee.init(BeeSerial, BEE_VCC, BEEDTR, BEECTS, 1024);
  wifiBee.connectionSettings(SSID, "", PASSWORD);
  uint16_t code = 0;
  wifiBee.HTTPGet("www.validsite.com/iot/index.asp", 80, "/?iotdata=" + code, "", code);

I am getting following message:

NodeMCU 0.9.5 build 20150318 powered by Lua 5.1.4
lua: cannot open init.lua

wifi.setmode(wifi.STATION)
wifi.sta.config(“UPC637985”,“xxxxxxxx”)
wifi.sta.connect()
print("|" … “STS|” … wifi.sta.status() … “|”)
|STS|1|
print("|" … “STS|” … wifi.sta.status() … “|”)
|STS|1|
print("|" … “STS|” … wifi.sta.status() … “|”)
|STS|5|
Success: IP received
wifiConn=net.createConnection(net.TCP, false)
wifiConn:on(“connection”, function(s) print("|C|") end)
wifiConn:on(“reconnection”, function(s) print("|RC|") end)
wifiConn:on(“disconnection”, function(s) print("|DC|") end)
wifiConn:on(“sent”, function(s) print("|DS|") end)
wifiConn:on(“receive”, function(s, d) lastData=d print("|DR|") end)
wifiConn:connect(80,“www.validsite.com/iot/index.asp”)
DNS retry 1!
DNS retry 2!
DNS retry 3!
DNS retry 4!
DNS Fail!

Where should I look further ?
Perhaps a small working example might help …
thanks,

Regards,
Barani !

hi

I got little further with the testing.
Now I am getting below error
HTTP Error 400. The request hostname is invalid.

NodeMCU 0.9.5 build 20150318 powered by Lua 5.1.4
lua: cannot open init.lua

uart.write(0, “OK\r\n”)
OK
wifi.setmode(wifi.STATION)
wifi.sta.config(“UPC637985”,“xxxxxxx”)
wifi.sta.connect()
print("|" … “STS|” … wifi.sta.status() … “|”)
|STS|1|
print("|" … “STS|” … wifi.sta.status() … “|”)
|STS|1|
print("|" … “STS|” … wifi.sta.status() … “|”)
|STS|5|
Success: IP received
wifiConn=net.createConnection(net.TCP, false)
wifiConn:on(“connection”, function(s) print("|C|") end)
wifiConn:on(“reconnection”, function(s) print("|RC|") end)
wifiConn:on(“disconnection”, function(s) print("|DC|") end)
wifiConn:on(“sent”, function(s) print("|DS|") end)
wifiConn:on(“receive”, function(s, d) lastData=d print("|DR|") end)
wifiConn:connect(80,“http://www.validsite.com”)
|C|
sb=""
sb=sb…“GET”
sb=sb…" "
sb=sb…"/?iotdata=1"
sb=sb…" HTTP/1.1\r\n"
sb=sb…“HOST: "
sb=sb…“http://www.validsite.com
sb=sb…”:"
sb=sb…“80”
sb=sb…"\r\n"
sb=sb…“Accept: /\r\n”
sb=sb…"\r\n"
wifiConn:send(sb) sb=""
|DS|
|DR|
uart.write(0, “|” … “SOF|”) for i=1, lastData:len(), 1 do ua(0, string.format("%02X", lastData:byte(i))) end uart.write(0, “|EOF|”)
|SOF|485454502F312E31203430302042616420526571756573740D0A436F6E74656E742D547970653A20746578742F68746D6C3B20636861727365743D75732D61736369690D0A5365727665723A204D6963726F736F66742D485454504150492F322E300D0A446174653A205361742C2032332041707220323031362032323A33333A333520474D540D0A436F6E6E656374696F6E3A20636C6F73650D0A436F6E74656E742D4C656E6774683A203333340D0A0D0A3C21444F43545950452048544D4C205055424C494320222D2F2F5733432F2F4454442048544D4C20342E30312F2F454E2222687474703A2F2F7777772E77332E6F72672F54522F68746D6C342F7374726963742E647464223E0D0A3C48544D4C3E3C484541443E3C5449544C453E42616420526571756573743C2F5449544C453E0D0A3C4D45544120485454502D45515549563D22436F6E74656E742D547970652220436F6E74656E743D22746578742F68746D6C3B20636861727365743D75732D6173636969223E3C2F484541443E0D0A3C424F44593E3C68323E4261642052657175657374202D20496E76616C696420486F73746E616D653C2F68323E0D0A3C68723E3C703E48545450204572726F72203430302E20546865207265717565737420686F73746E616D6520697320696E76616C69642E3C2F703E0D0A3C2F424F44593E3C2F48544D4C3E0D0A|EOF|> wifiConn:close()

Power OFF
Result code: 400
Response:
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Sat, 23 Apr 2016 22:33:35 GMT
Connection: close
Content-Length: 334

Bad Request

Bad Request - Invalid Hostname


HTTP Error 400. The request hostname is invalid.

</HTML�

There some issue with the URL/URI that you are attempting to “GET” from.
It is difficult to say what the issue is exactly without seeing the exact details.

This is incorrect. Parameter 1 should is the host, parameter 2 the port, and parameter 3 is the location on the host and any REST parameters.

It should look something like this:

wifiBee.HTTPGet("www.validsite.com", 80, "/iot/index.asp?iotdata=123", "", code);

Hi

I got that right in my second post. Only Hostname is used now.
But now I get HTTP/1.1 400 Bad Request.

Does it related to too many bytes submitted ?
#define TEST_HEADERS “Accept: /\r\n”

To get understand this properly … does the WIFI calls the hostname with parameters ?
I capture the parameters in the webpage. Hope, I am on the right path ?

Result code: 400
Response:
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Sat, 23 Apr 2016 23:41:36 GMT
Connection: close
Content-Length: 334

Bad Request

Bad Request - Invalid Hostname


HTTP Error 400. The request hostname is invalid.

What is the actual host and page you are trying to connect to?

Hi Gabriel,

Thanks for all your answers so far.

I am using the following parameter:

hostname:
http://www.ezee-solutions.com/

parameter:
iot/capturerawdata.asp?iotdata=123

You should see the captured results under this:
http://www.ezee-solutions.com/iot/capturerawdata.asp

Regards,
Barani !

I’ve tested this and it works:

uint16_t code = 0;
wifiBee.HTTPGet("www.ezee-solutions.com", 80, "/iot/capturerawdata.asp?iotdata=321", "", code);

However, you will have issues reading the response. The response arrives in multiple packets and causes some issues with the available memory on the WifiBee.

You should look at modifying the response from your server to be a simple acknowledgement of success.

Many thanks Gabriel.

Indeed it works at my end as well.
I have removed some forward slashes and it works like a charm.

I don’t understand your remark with available memory.
From WIFI Bee … i only have one main piece of code, which you wrote above.
Could you please elaborate what should I modify ?
Sending data through iotdata= parameter should be limited ?

Thanks once again,

Regards,
Barani !

Hi Barani,

The basic process that the Wifibee library uses is this. The request is generated and sent to the server. The response from the server is saved in a buffer on the NodeMCU Wifibee module. That buffer is then read back to the MCU (Autonomo).

I’ve pushed some changes to the repository today:

In your particular use case you are receiving a very large response (30-60KB). This highlighted a few issues which I have addressed in today’s commits. The issues were due to the large size of the response. In this case, the response was actually being sent in multiple packets, something that previously was not being handled correctly. Also due to the length of data there was an issue with the watch dog timer on the NodeMCU resetting the board. There was also a few other time out problems.

Currently, only the first packet of the response is saved. This is mainly due to memory restrictions. I tried to concatenate the packets as they arrived, but this caused issues with running out of memory and with hitting the buffer size limitations of Lua. Previously I experimented with using the file storage on the NodeMCU to store the response, I may revisit this once again.

Ok. Thanks for the elaborate explanation.
I will modify the webpage to return simple acknowledgement of success.

Meanwhile, how do i modify the already added library. When I add new .ZIP files, it prompts error saying library already exists.

Regards,
Barani !

On the Windows platform the library files are stored at:
/Users//Documents/Arduino/libraries

You can replace the files in the Sodaq_WifiBee subfolder directly.
Alternatively you could clone the repository into that location.