Community
OpenEnergyMonitor

OpenEnergyMonitor Community

Avoiding wireless connections - EmonTX serial RPiZero solution

I find even some 1 Amp supplies are fine, slightly bulkier, possibly non-switching types.

The emonBase are under-clocked as we know, so the full 2A is not often totally necessary perhaps.

The red LED on the pi is a good indicator of power quality neh? Continuously on red = good enough?

I think I now have all of the bits I need, but a couple of quick questions as the PiZero doesn’t show up within my router’s CP (although the small green LED does come on / flash) …

I added a (blank) ssh.txt file and a wpa_supplicant.conf file to the boot partition - the contents of the latter being

Should I expect the Pi Zero to “work” without being connected to an emonTx or not? Maybe I have tried to run before I can walk, as I have not yet connected the emonTx.

TIA

I don’t have update_config in the file I use.

It is just SSH not SSH.txt AFAIK.

Yes get the Pi working first and it should just work IME. If not, connect up to a monitor and see what it is saying. If a new emonSD image, usual caveats re allowing it to finish updating before removing power or rebooting.

1 Like

Many thanks; still not appearing in my router’s list of clients, so probably a wifi thing. I needed to obtain a mini-HDMI adapter (just arrived now), so will try to hook up a monitor tomorrow.

1 Like

Note that it’s specifically ssh (lower-case) rather than SSH.

By default SSH access is disabled in Raspbian. To enable SSH, create a file called ssh and save it to the root directory of the boot mount on the SD card. The file can be blank, and it has no extensions. It should exist at the same location as the other files that were edited.

From https://www.thepolyglotdeveloper.com/2016/06/connect-raspberry-pi-zero-usb-cable-ssh/ which explains how to make a wired connection if the wireless is causing grief.

2 Likes

I re-flashed the emonSD on to a 16GB microSD card, added an amended wpa file, and an ssh file. I don’t have access to a microUSB keyboard or mouse, so just attached the Zero c/w EmonTx to a TV via HDMI; several boot pages scrolled up (too fast to read), but then stopped at this one.

Can one learn anything from what it says? Can one deduce whether or not it has connected to the internet? It still isn’t showing on my router’s CP, so I suspect not. I googled “Failed to start Log2Ran” but couldn’t find anything. I’ll give @djh 's usb>ssh url a try later.

TIA

Which image? The 2019 one?

It is actually Log2Ram and @TrystanLea has been having troubles with that on the new (2020) image.

I used emonSD-17Oct19.img , as found on https://github.com/openenergymonitor/emonpi/wiki/emonSD-pre-built-SD-card-Download-&-Change-Log - but perhaps I should have been more brave and used the emonSD-24Jul20 one.

Odd. Not sure why it isn’t working then.

1 Like

I know

The overclock settings are wrong fro a PiZ.

Edit /boot/config.txt comment out this line (and one below it IIRC)

arm_freq

Solved in the new Image.

1 Like

https://www.raspberrypi.org/documentation/configuration/config-txt/overclocking.md

says the Pi Zero CPU clock is 1 GHz:

image

Or are you just having some good natured “fun?”

You can comment the settings out and let it default.

Edited above - didn’t mean to leave a figure in, just meant to say comment out the line.

thumbsup

Woo Hoo! Commenting out those two lines ( arm_freq=1200 and gpu_mem=16 ) & rebooting the Pi Zero, and it appears in the router’s CP.

After typing in the LAN IP I get the “Welcome to your emonPi” page. This is presumably what @lgheorghe was seeing on Getting setup wizard page instead of login . I clicked on the wifi option, and then after reconnecting to emonpi.local I get in to a bit of a loop - searching for networks (again).

Not sure how important this is - possibly related to the above - but above the Welcome page there is a warning message

**Warning** : file_get_contents(/etc/wpa_supplicant/wpa_supplicant.conf): failed to open stream: Permission denied in **/var/www/emoncms/Modules/setup/setup_model.php** on line **24**

The Pi is powered through my emonTx, with the wires connected as per @pb66 's second schematic:
4: 5v > 5v
6: Gnd > gnd
8: tx > tx
10: rx > rx
12: p12 > rts

I am able to ssh in to the Pi, but my linux skills are so limited that I although I am able to use some very basic commands (cd and ls etc), am not yet able to poke around (or change) anything. (EDITORS Note: Good job probably :grinning: )

So, progress (thank you all), but still not quite there yet.

what are the permissions of /etc/wpa_supplicant/wpa_supplicant.conf?
i.e. what’s the result of

ls -l /etc/wpa_supplicant/wpa_supplicant.conf

Last login: Thu Aug 27 09:20:24 2020 from 192.168.2.30
[email protected] : ~ $ ls -l /etc/wpa_supplicant/wpa_supplicant.conf
-rw------- 1 root root 219 Aug 27 09:16 /etc/wpa_supplicant/wpa_supplicant.conf
[email protected] : **~ $

Well I suppose that setup_model.php is run as the pi user, so it won’t be able to read that, as it says. wpa_supplicant.conf is -rw-r–r-- 1 root root on my emonBase so I suppose you need to add the extra read permissions. i.e.

sudo chmod go+r /etc/wpa_supplicant/wpa_supplicant.conf

I don’t understand why it was -rw------- to begin with though. How was it created?

edit: I just looked at a pi zero i fairly recently set up with buster and wpa_supplicant.conf is root-only access on there too (there’s no emoncms on that m/c) so perhaps there’s some conflict between raspbian defaults and emoncms expectations? Maybe @TrystanLea would know?

Yeah those 2 lines have been an issue for quite sometime, unless you are running a Pi3. But I believe on the latest image @TrystanLea has now moved back to using the default setup (allowing the Pi to set these) which caters equally for all Pi’s.

What I believe is happening (and this is true and tested on the pre-emonscript images so may have carried over) is that your wpa_supplicant file in the boot directory is overwriting the OEM’s (modified permissions) file at start up as it is designed to in the OS image, then the OEM stuff (emoncms?) isn’t able to read/write as needed.

This has been addressed in previous images by loading the image to a sdcard then putting it in a Pi with Ethernet so that you can modify the location and symlink the OEM copy and then you can modify the wpa_supplicant file at will on a PC or via ssh or indeed still use the emoncms setup.

See Wifi config on Pi Zero using emonSD although the rpi-rw is no longer needed and I think the source location of the OEM file has maybe changed to.

Brian or Trystan may be able to advise more on the current image, I have to say I thought this was going to be implemented on the emonScripts images TO enable the use of Pi Zero’s without any additional difficulties. Perhaps that was missed or not working quite right? What files do you have in the boot folder?

ls -la /boot

anything there wifi related that isn’t the wpa_supplicant file?

What is odd is that this has just worked for me (adding in the wpa file) in the recent past.

Thanks all - very interesting. In case it is of help / use, herewith the result of ls -la /boot

[email protected] : ~ $ ls -la /boot
total 52574
drwxr-xr-x 4 root root 4096 Jan 1 1970 .
drwxr-xr-x 21 root root 4096 Oct 17 2019
-rwxr-xr-x 1 root root 23966 Oct 17 2019 bcm2708-rpi-b.dtb
-rwxr-xr-x 1 root root 24229 Oct 17 2019 bcm2708-rpi-b-plus.dtb
-rwxr-xr-x 1 root root 23747 Oct 17 2019 bcm2708-rpi-cm.dtb
-rwxr-xr-x 1 root root 23671 Oct 17 2019 bcm2708-rpi-zero.dtb
-rwxr-xr-x 1 root root 24407 Oct 17 2019 bcm2708-rpi-zero-w.dtb
-rwxr-xr-x 1 root root 25293 Oct 17 2019 bcm2709-rpi-2-b.dtb
-rwxr-xr-x 1 root root 25422 Oct 17 2019 bcm2710-rpi-2-b.dtb
-rwxr-xr-x 1 root root 26463 Oct 17 2019 bcm2710-rpi-3-b.dtb
-rwxr-xr-x 1 root root 27082 Oct 17 2019 bcm2710-rpi-3-b-plus.dtb
-rwxr-xr-x 1 root root 25277 Oct 17 2019 bcm2710-rpi-cm3.dtb
-rwxr-xr-x 1 root root 40559 Oct 17 2019 bcm2711-rpi-4-b.dtb
-rwxr-xr-x 1 root root 52296 Oct 17 2019 bootcode.bin
-rwxr-xr-x 1 root root 98 Aug 27 09:12 cmdline.txt
-rwxr-xr-x 1 root root 4096 Aug 27 09:34 ._config.txt
-rwxr-xr-x 1 root root 1821 Aug 27 09:15 config.txt
-rwxr-xr-x 1 root root 18693 Oct 17 2019 COPYING.linux
-rwxr-xr-x 1 root root 0 Oct 17 2019 emonSD-17Oct19
-rwxr-xr-x 1 root root 0 Jan 1 1980 emonsdinit
-rwxr-xr-x 1 root root 3073 Oct 17 2019 fixup4cd.dat
-rwxr-xr-x 1 root root 6167 Oct 17 2019 fixup4.dat
-rwxr-xr-x 1 root root 9247 Oct 17 2019 fixup4db.dat
-rwxr-xr-x 1 root root 9249 Oct 17 2019 fixup4x.dat
-rwxr-xr-x 1 root root 2657 Oct 17 2019 fixup_cd.dat
-rwxr-xr-x 1 root root 6736 Oct 17 2019 fixup.dat
-rwxr-xr-x 1 root root 9808 Oct 17 2019 fixup_db.dat
-rwxr-xr-x 1 root root 9810 Oct 17 2019 fixup_x.dat
-rwxr-xr-x 1 root root 145 Sep 26 2019 issue.txt
-rwxr-xr-x 1 root root 5310624 Oct 17 2019 kernel7.img
-rwxr-xr-x 1 root root 5628040 Oct 17 2019 kernel7l.img
-rwxr-xr-x 1 root root 13230592 Oct 17 2019 kernel8.img
-rwxr-xr-x 1 root root 5029176 Oct 17 2019 kernel.img
-rwxr-xr-x 1 root root 1494 Oct 17 2019 LICENCE.broadcom
drwxr-xr-x 2 root root 15872 Oct 17 2019 overlays
drwxr-xr-x 4 root root 512 Aug 26 15:31 .Spotlight-V100
-rwxr-xr-x 1 root root 4096 Aug 26 15:34 ._ssh.txt
-rwxr-xr-x 1 root root 770816 Oct 17 2019 start4cd.elf
-rwxr-xr-x 1 root root 4733128 Oct 17 2019 start4db.elf
-rwxr-xr-x 1 root root 2769540 Oct 17 2019 start4.elf
-rwxr-xr-x 1 root root 3683816 Oct 17 2019 start4x.elf
-rwxr-xr-x 1 root root 685668 Oct 17 2019 start_cd.elf
-rwxr-xr-x 1 root root 4854728 Oct 17 2019 start_db.elf
-rwxr-xr-x 1 root root 2877988 Oct 17 2019 start.elf
-rwxr-xr-x 1 root root 3792232 Oct 17 2019 start_x.elf
-rwxr-xr-x 1 root root 4096 Aug 26 15:34 ._wpa_supplicant.conf
[email protected] : ~ $

Would it still be a good idea to run this command ?

sudo chmod go+r /etc/wpa_supplicant/wpa_supplicant.conf