Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

baxter

Member Since 27 Jul 2011
Offline Last Active Mar 13 2016 07:29 PM
-----

Posts I've Made

In Topic: Unique device ID

29 May 2015 - 04:27 PM

See post #8,
http://forums.netdui...uino-unique-id/


In Topic: Serial Port read data

14 April 2015 - 05:57 PM

I was using this with an ESP8266 AT command set driver (since abandonded in favor of the Lua firmware). Just instantiate the port without an event handler and then receive serial in a wait loop.

Public Sub New(ByVal ComPort As String, _
                   Optional ByVal baud As Integer = 9600)
        Port = New SerialPort(ComPort, baud, Parity.None, 8, StopBits.One)

        With Port 'note no event handler
            .Handshake = Handshake.None
            .WriteTimeout = 200
            .ReadTimeout = 200
            .Open()
        End With
        InputString = String.Empty
        'need to change if not 9600
        If (baud <> _DefaultBaud) Then '9600 is default baud rate of ESP8266 firmware (0.9.2.2)
            _Baud = baud
        End If
    End Sub

---------------

Public Function GetFromESP(Eot As String) As String
        'this is the main reader for ESP responses. It will wait for the expected Eot or
        'a socket exception will be thrown if the response contains, ERROR or Unlink

        Dim n As Integer = 0
        Dim response As String = String.Empty
        InputString = String.Empty
        While (True)
            If (Port.BytesToRead > 0) Then
                Dim buff = New Byte(Port.BytesToRead - 1) {}
                n = Port.Read(buff, 0, Port.BytesToRead)
                Thread.Sleep(200)
                InputString &= New String(Encoding.UTF8.GetChars(buff))
                'Debug.Print("Inputstring: " & InputString)

                If (Contains(InputString, Eot)) Then 'expected return
                    Exit While
                    'Trap for socket connect to inactive server
                ElseIf (Contains(InputString, "CIPSTART") And _
                       (Contains(InputString, "ERROR") _
                        Or Contains(InputString, "Unlink"))) Then
                    response = InputString
                    InputString = String.Empty
                    Throw (New ESPexception("Socket can't connect: GetFomESP returned ERROR Unlink"))
                End If
                Thread.Sleep(50) 'need this delay (maybe more)
            End If
        End While
        response = InputString
        InputString = String.Empty
        Return response
    End Function

In Topic: 12 water flow sensors 160ft away from N+2

05 March 2015 - 07:32 AM

The ESP8266 WiFi modules might be a nice fit for your project.  When using the nodeMCU Lua firmware they basically become programmable wireless access points. The ESP-01 costs about $3 and exposes 2 GPIOs. The modules operate as a TCP client or server or both. Out of the box firmware uses an AT command set, but the Lua firmware offers much more and is very stable. They require about 240 ma when talking on the network and 70 ma when not. They are also 3.3V and not 5V tolerant. The disadvantage is that one needs to learn a bit of Lua, but there are plenty of examples in the nodeMCU forum link below.

 

GPIO2 supports an interrupt to count pulses for your sensor and the latest version of Lua has floating point math so you could directly compute the flow rate on each ESP module. Each ESP module also has its own MAC address and a chipID for identification, accessable via Lua functions. There is also a Lua repeatable timer alarm  with a callback function. This is where you could do your calculations and send the flow rate with an ID every X seconds via TCP or UDP.

 

The range in open air has been reported as 366 meters with the PCB antenna. This, however, is optimistic in the real world. I have an ASUS RT-n66U router and about 40 feet away from it, through 2 walls and a floor, a laptop shows 5 bars for the network SSID. For an ESP under the same conditions, the ESP broadcast SSID shows 2 bars signal strength. Given your longer distances, you might need to add a wireless extender to the mix.

 

If you use them behind a wireless router, each of the modules can obtain an IPaddress with with Lua code like the following: (Lua has a file system and a file is executed with dofile("myfile.lua")


-- File name: init.lua
print("set up wifi mode") 
--this is sent back to serial terminal if connected, otherwise does nothing
wifi.setmode(wifi.STATIONAP)
wifi.sta.config("ret13x","XXXXXXXXX")
 --here SSID and PassWord should be modified according your wireless router
wifi.sta.connect()
tmr.alarm(1, 1000, 1, function() -- repeat function every 1000 ms
    if wifi.sta.getip()== nil then 
    	print("IP unavaiable, Waiting...") 
    else 
    	tmr.stop(1)
    	print("Config done, IP is "..wifi.sta.getip())
    	--dofile("yourfile.lua")
    end -- if
 end) -- function

The init code will run on a powercycle or soft restart. The dofile("yourfile.lua") above will run once an IPaddress has been obtained and this is where you could put your flowmeter stuff.

 

here are some links,

 

ebay seller (USA fast shipping)

http://www.ebay.com/...html?rmvSB=true

 

nodeMCU forum:
http://www.esp8266.c...wforum.php?f=17

 

nodeMCU firmware(see pre_build) :
https://github.com/n...odemcu-firmware

 

API instruction set:

https://github.com/n.../nodemcu_api_en

 

For development, I use LuaLoader and a PC console TCP client for testing networking:
http://benlo.com/esp....html#LuaLoader


In Topic: Which Micro SD Cards will work

03 December 2014 - 06:42 PM

I recall that Chris recommended a 2GB kingston from Amazon,

http://www.amazon.co...B/dp/B0015R2NUW


In Topic: Porting eLua to the NetDuino

17 November 2014 - 10:03 PM

I only tried the binary for the ET-STM32 Stamp.


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.