emonPi WiFi Access Point & 3G GSM USB dongle LCD

Over the weekend I put together a guide to use the emonPi in WiFi access point mode for offline or 3G GSM installs. This would be perfect for installs at a site where there is no Wifi or Ethernet, a 3G dongle can be used to provide 3G connectively and and the emonPi can broadcast it's own Wifi AP to allow Internet access to local Emoncms and also interent via the 3G dongle! emonPi 3G router anyone?

https://github.com/openenergymonitor/emonpi/blob/master/docs/wifiAP.md

Also related development the emonPiLCD script will now display info from Huawei HiLink 3G dongles such as connection state and signal strength. This data is obtained directly via a huawei API (tested with E3231). Follow this guide to setup Huawei HiLink dongle:. Initial testing with this dongle is going well, I found I need to use a powered hub USB y-cable to provide extra power to the dongle.  

https://github.com/openenergymonitor/huawei-hilink-status

Pulling all these developments together I want to improve our support for mobile connectivity 

 

To do: 

* Automate activating emonPi WiFi access point

*Build support for 3G dongles into emonPi image (plug n play)

* Test more dongles, can we find one that does not need a hub and has external antenna options? 

* Test reliability and regaining GSM connection when dropped

* Test antenna options for poor reception areas  

* Establish and optimize mobile data consumption, maybe emonPi autodetect mobile connection and turn on optimised data mode 

* Investigate network operator options - eventually it would be great to be able to offer the emonPi with a 3G dongle + SIM card pre loaded with enough data for 12 months of logging 

* Display data consumption on emonPi LCD from dongle APi

*Test how emonPi can be accessed remotely via 3G, reverse ssh? 

https://github.com/juslop/3G-tunnel

glyn.hudson's picture

Re: emonPi WiFi Access Point & 3G GSM USB dongle LCD

Following on from my exploration ino WiFi AP's I would like to improve the emonPi / emonBase setup process by having the unit broadcast it's own open-access wifi hotspot at first boot to allow the user to connect directly to it and enter their local WiFi network authentication details then save and reboot and the emonPi will then connect to users existing WiFi network as a client and turn off AP mode. Trystan previously made a start on this

I propose the following:

emonPi first boot:

1. AP setup Network interfaces file assigning a static IP to wlan0

2. Hostapd service broadcasting a Wifi hotspot 

3. isc-dhcp-server running to allow user to connect to hotspot via DHCP

4. User connects to hotspot and get's directed to Emoncms (or a custom Wifi config service), enters WIfi network name and password (for the emonPi to be able to display Wifi networks we would need a Wifi adapter to support both client and AP mode, is this possible?). User saves config and reboots. 

5. Unit reboots with standard Raspberry Pi  network interfaces file

6. Hostapd and isc-dhcp-server services disabled 

6. wlan0 gets assigned an IP via DHCP from client network (static IP could also be an option) 

7. Unit operates as usual in client mode

 

To do

* Changing network interfaces file could be done via bash script using symlinks 

Emoncms Wifi module to be extended to add static IP config option 

 

Questions

1. Can Edimax Wifi dongle an Pi3 integrated Wifi operate both in AP and client mode at the same time? 

 

glyn.hudson's picture

Re: emonPi WiFi Access Point & 3G GSM USB dongle LCD

Some discussion on this topic here, I think managed (client) + AP mode should be possible on most Wifi hardware:

http://superuser.com/questions/1035755/rtl8188-ap-and-client-mode-simult...

Bbaass_TMH's picture

Re: emonPi WiFi Access Point & 3G GSM USB dongle LCD

Concerning emonPi / emonBase first boot in hotspot mode: would there be an option to re-enable this setting without doing a full factory reset? For those of us who use the system as a temporary installation and need to connect it to a different network on a semi-regular basis.

glyn.hudson's picture

Re: emonPi WiFi Access Point & 3G GSM USB dongle LCD

Yes certainly, it could be activated by hitting the Reset button. 

pb66's picture

Re: emonPi WiFi Access Point & 3G GSM USB dongle LCD

"I found I need to use a powered hub USB y-cable to provide extra power to the dongle. "

By default the Pi's usb ports are restricted to 600mA, but the B+, 2B and 3B are capable of delivering up to 1.2A via the usb ports providing the supply to the Pi is up to it. if you haven't already try adding

max_usb_current=1

to the end of /boot/config.txt and reboot.

I use this for connecting spinning hard-drives directly to Pi's without a separate hub, power supply or Y-lead, 1200 mA is plenty for most hdd's and I would hope, way more than you need for the 3g dongle.

Paul
  

glyn.hudson's picture

Re: emonPi WiFi Access Point & 3G GSM USB dongle LCD

Woo nice find. Are there any side effects to enabling max current? Why not have it enabled by default? 

glyn.hudson's picture

Re: emonPi WiFi Access Point & 3G GSM USB dongle LCD

I've answered my on question (thank you Internet!)

"All that max_usb_current=1 does is to set GPIO38 high, which in turn turns on a FET, which connects a second 39K resistor in parallel to an existing one, on pin 5 of U13, the AP2553W6 USB power manager, lifting the current limit from 0.6A to double that (1.2A), see no possible scenario there why the PI resets because of that, except in case the gate of the FET Q4 is somehow shorted to GND. Which could be caused by a production fault. Inspect Q4, as look if there is solder shorting pins together. Also R6 (resistor mounted between gate of Q4 and GND) should be 100K not 0 Ohm. U13, Q4 and R6 should be near the USB ports."

Reading the Pi forums is seems there are no negative impacts of having this turned on by default except the fact the Pi could potentially draw up to 2A from a PSU (if high power peripherals are plugged in) which could cause damage to cheap PSUs. The PSUs we ship with the emonPi are only 1.2A but high quality with dependable current limiting circuits. I see no problem powering a GSM USB stick, or USB HDD (maybe not both!). 

Today I measured the power draw of a RasPi 3, I observed some peak current draws of 0.6A and idle around 0.3A. Pi2 is more like 0.4A peak and 0.26A idle.  It would be interesting to measure Pi2 + USB wireless adapter to see if this is lower or higher then Pi3. Obviously the lower the better with regard to a 24/7 energy monitoring device! 

Some official measurements:

http://raspberrypi.stackexchange.com/questions/43285/raspberry-pi-3-vs-p...

Eric_AMANN's picture

Re: emonPi WiFi Access Point & 3G GSM USB dongle LCD

Hi,

Facing issues when connecting emonbase to existing wifi/ethernet networks, I'm very interested by these new EmonPi dev.

Would it be possible to modify emonhub to reduce the amount of data uploaded/downloaded through the 3G network ?

Eric

glyn.hudson's picture

Re: emonPi WiFi Access Point & 3G GSM USB dongle LCD

Hi Eric, 

Wifi connectivity should be improved with this update. 

I have just updated emonhub to allow setting the buffer interval for posting to Emoncms.org. 

https://github.com/openenergymonitor/emonhub/commit/050b6139f3bf07b0930d...

After updating emonhub (with a  git pull) you can set in emonhub.conf sendinterval= XX where XX is the time in seconds between posts to emoncms.org. Default is 30s. e.g 600 would be 10min

Eric_AMANN's picture

Re: emonPi WiFi Access Point & 3G GSM USB dongle LCD

Hi,

Do you have a rough idea how it will affect the amount of data downloaded/uploaded by emonhub ? In your example, can we expect a reduction by 600/30 = 20 ? More ? Less ?

Eric

 

 

glyn.hudson's picture

Re: emonPi WiFi Access Point & 3G GSM USB dongle LCD

Probably less, since we are sending the same amount of data it's just being buffered for longer. However we will reduce the amount of data used in the HTTP header request by sending in bulk. We are undergoing testing at the moment to find out for sure.  

glyn.hudson's picture

Re: emonPi WiFi Access Point & 3G GSM USB dongle LCD

Bit of progress on Wifi AP setup, I've made a script to start and stop WiFi AP mode. 

It works starting WiFi AP when emonPi is in normal Wifi mode without any rebooting and then when AP is stopped normal client mode is resumed.

The script also bridges eth1 (USB 3G dongle) to the WiFi AP. This will be useful when using emonPi with 3G dongle, this will allow a local user to connect to the emponPi via Wifi AP, to connect via SSH, view data locally and even get internet via the 3G dongle...an emonPi 3G router! 
 

The script assumes hostpad and dhcp is setup as detailed in my guide. Script has only been tested on RasPi3 using standard version of hostapd. Using hostapd with Edimax dongle is a pain since it requires compiling a upstream version from source. For this reason all development in this topic will be done on RasPi3 / offical Broadcom Wifi dongle. 

To install, git pull latest emonpi master and symlink the script:

cd emonpi

git pull

sudo ln -s /home/pi/emonpi/wifiAP /sbin/wifiAP

​then run 

sudo wifiAP start

This will start a Wifi AP with SSID emonPi and password 'raspberry' 

Then to stop

sudo wifiAP stop

The final piece to allow the AP to be used for fist boot setup  is the ability to operate in both client+AP mode at the same time to allow scanning for networks while connected in AP mode. This is technically possible. The raspi3 supports AP+client mode at the same time (see output for $ lw list). I'm just not sure how to configure...I'm monitoring some topics on the RasPi forums for any info.

https://www.raspberrypi.org/forums/viewtopic.php?f=36&t=138730&p=931772#...

https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=134614&p=931751#...

I think what's needed to to create a virtual interface. I've tried this method but am failing to get the virtual interface to bind to the physical adapter (driver issue?): 

http://superuser.com/questions/615664/creating-wifi-access-point-on-a-si...

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.