Raspberry Pi Zero WiFi

Raspberry Pi Zero WiFiI should have just entitled this “Raspberry Pi” as it keeps expanding (now covering the rest of the Pi boards – but keep reading).. as you will see, the title is a little restrictive given what we’ve done over the last few days. Friend Antonio over Italy and I (still stuck here in the frozen wastes of the Northeast of England) have been working quietly in the background on making the script compatible with the new Raspberry Pi Zero WiFi (RPiZW) having already managed to get it working on a range of boards and operating systems including RPi2, RPi3, Debian, Xenial, various Orange Pi boards, various FriendlyArm boards, the Odroid C2 and more.

At under a tenner, no-one can claim this tiny WIFI enabled RPiWZ is going to break any records. It is slow. very slow compared to a Raspberry Pi 2 or perhaps an Orange Pi Zero... and at first attempt I nearly gave up after waiting a whole day for my script to run (and fail) - something that can take maybe an hour on more powerful single board computers such as the RPi3 or the Odroid C2 etc.

However, having failed to get the script to run on the official Raspbian distribution for this board, for a variety of reasons, we next tackled DIETPI. Here, this slimmed down operating system comes into it's own and the PI Zero WiFi runs a lot more swiftly than it does with stock Raspbian. Still, by lunchtime yesterday I'd stopped the script due to various errors. By late last night however, with a little manual injection I had everything running on this tiny board - Apache, PHP, Node-Red with all my usual Nodes, MQTT, Sqlite, PhpLiteAdmin, Ha-Bridge, MC and much more, all with no manual intervention (just as well, given the time it takes).

This weekend while I was out shopping for a new milk-frother, our friend Antonio over in Italy was busy working on some last minute amendments to the script which, you'll recall now runs on a range of devices and systems including Xenial and Debian. We’ve now completed the  updates to the script, including the ability to run on the RPiZW.  The sheer size of the RPiZW (or rather lack of it, being exceedingly thin) means you could fit this board, able to control a house, on the back of an LCD display and have the whole thing mounted in a reasonably slim wall-mounting box. The Orange Pi Zero on the other hand has that large Ethernet connector which means a slim case is out of the question.

There is of course competition for this board, the Nanopi Neo Air is actually smaller (different format of course, being square) - and no doubt a lot faster - but like the RPiZW it has no Ethernet. One issue I've had with many boards is that of WIFI reliability. Up to now, the WIFI on the RPiZW is rock-solid - just as well, as it doesn't have hardwired Ethernet capability (well, not without some soldering or a compact-size-defeating USB dongle). The NanoPi on the other hand works well and is way better technically but I'm not 100% happy about the WIFI on the latter. All of this could change of course with future software updates.

Raspberry Pi Zero WiFi: Here’s what I did (total time 4 hours -  VERY little of which I was actually doing anything – well, watching YouTube videos actually):

  • I grabbed the file DietPi_v145_RPi-armv6-(Jessie).img
  • I used SD Formatter to format a 16GB card then Win32 Disk Imager to blow the image onto the SD card.
  • I plugged the card into the RPiZW and powered the board up, plugged into a screen – and with keyboard and mouse connected via a USB hub.
  • I started up the Pi – that takes a little while and it eventually wants you to login as root (initial password dietpi).
  • As per initial dialogs in DietPi-Config, I set up the WIFI.
  • The board went off to do some downloading and came back to the DietPi-Software - I swapped from DropBear to OpenSSH Server and lighttpd to Apache2 - but didn’t install anything else.
  • At the end of that I could get into the board remotely using WINSCP and no longer needed the keyboard and mouse.
  • I copied the script across to the root directory – ensuring it was in Linux format (Line feeds only) and that it had execute permission.
  • It went off and automatically set up a PI user with password “password”. I logged into the board (using WinSCP) as user  pi. I copied the script across again and once again made sure it had execute permissions. I ran the script.
  • Several items were downloaded. I waited patiently until the main menu came up. I accepted all defaults but added HA-Bridge.
  • I was asked for a user name (user) and password – and an admin name (admin) and password… (you can opt out of that now and leave defaults if you like) and at that point the script – as you’d expect – went off for 4 hours (using a half-decent microSD from Samsung) doing it’s own thing. And yes, watching the WEBMIN setup DOES feel like watching paint dry.
  • At the end of all of this – I rebooted the board – and that was the end of that – a perfectly working RPiZW.

Something that has come out of this – is the importance of SD speed… I’ve always known this but NEVER has it been as obvious as it is here with this slower board. 4 hours – recall I mentioned an earlier attempt which failed but also took longer. Well, now I’m using a decent Samsung microSD.

Raspberry Pi Original: Which brings me to the Raspberry Pi – not the 2 or 3 but one of the originals. The script appears to be working perfectly now even on pre-Pi2 boards with full size SD card (Raspberry Pi © 2011.12). Sadly when I was using those I was not aware of the need for the best SD and THIS install took 7.25 hours – if you plan to try one of these – get a decent SD! Still – all working so an otherwise useless Pi is now up and running.

Raspberry Pi Zero: On a whim, I took a copy of the microSD I used on the RPiZW and dropped it into the lowly, cheap and cheerful Raspberry Pi Zero (the one with nothing) – I then took a USB adaptor and plugged it in, with one of those really cheap unbranded WiFi USB blocks at the other end.  I plugged in power, waited, checked for new IP addresses and LO AND BEHOLD that was online too!

Raspberry Pi 2:  I tested the modified script on the Pi2 and as well as being a darn sight faster to install than the units above – it does work well.  I did however notice that the yellow Node-Red GPIO node does not work – possibly something missing in DietPi. However – there’s a great utility called GPIO which gives you full command line access and I’ve now added that as an option to the script. I’ve tried GPIO access including PWM and it all works a treat as Pi user.

cd
git clone git://git.drogon.net/wiringPi
cd ~/wiringPi
./build

The above it what I added… then use GPIO – now, with the –g option, the pins correspond to the actual connector which is nice – so for a nice dim LED on GPIO13

gpio –g mode 13 pwm
gpio –g pwm 13 20

Not tried that on the Zero but I assume it will work as well. If anyone knows why that yellow GPIO node sits at “connecting” do let me know. Remember in all of this we’re using the DIETPI image – NOT original Raspbian – which IMHO is a little heavy handed if you don’t want a graphical interface.

Things are looking up.

Raspberry Pi backupAnd now for something completely different: Meanwhile I thought you might like to see this Raspberry Pi battery backup  (not for good reasons) -   I bought this a couple of weeks ago and it turned up today. 4 brass spacers and it fits onto my Raspberry Pi 3 a treat.

But – pull the power out – and the Pi reboots – who on EARTH dreamed this up!!! They claim 9 hours of backup but no good if power loss causes a reset… worse -  I bought it from Europe at £9.49 and I COULD have bought it from where they probably got it from in the first place at £8.73 and no postage. Oh well. I’m assuming I got a bad one – surely they could not have designed it this way. Anyway, it has a 3800maH battery and it all fits perfectly on the back of a Pi.  On the FRONT of my Pi I have an LCD display and the whole thing was intended to form the backbone of my updated home control in Spain when we go back there in April. A clue to the problem may be that there is a small yellow power indicator on the Pi, suggesting the pack might just be putting out insufficient voltage for the Pi + LCD. So – I tried it with a Raspberry Pi 2 on it’s own – same result. Just thought you’d like to know in case you were thinking of buying one of these. THIS looks GOOD (Thanks Antonio) – any experience of this??  I have some goodies from another company coming in the next couple of weeks which look promising as uninterruptable supplies– more on this soon.

Facebooktwittergoogle_pluspinterestlinkedin

96 thoughts on “Raspberry Pi Zero WiFi

  1. Glad you found the WiFi reliable, I've been testing my hot water control interface for a week and all seems to be OK so I'm planning in installing in the airing cupboard this weekend. The family can control it from the dashboard interface on their phones or an Amazon Dash button for a 30 min boost and I'm planning a "Son had Shower" detection function to automatically boost the water when my son takes one of his never ending showers 🙂

    1. oh, 1 difference towards all the remaining boards: in this case php is still at version 5, as php7 is not available in a precompiled version for armv6 arch, and the other way (compiling from sources) is a no-no... i prefer to live without waiting this little beast to complete a source build... but, on the good side, script should now work on raspberry 1B, too... just saying, needs testing 🙂

  2. First, yup got one, very cool! Isn't this $#7+ great !

    I find that everyone call it slow to be a bit weird. Slow when compared to what? If they're expecting it to be faster than your desktop then you'll be disappointed but if you've expecting it to be faster than a computer from roughly 1997 then it's pretty good. Beats the Arduino in most things (not real time though).

    But I will agree the Pi is not good for everything. But this Pi W is pretty cool, the Arduino and ESPs usage just got a little smaller.

    You young kids (Yea you Pete) are spoiled with Pi W. When I was a kid we had cardboard, rubber bands and paper clips (the paper computer). And it only hertz'd when you snapped a paper clip on a rubber bad against you finger. 😉

    And for the humor impaired ... think about it ...

      1. Thanks for the honest reply, I've just heard "it's slow' from so many people and they never say what they're comparing it to. Most of these people play with either Arduinos or Windows.

        I get a bit worked up when I'm not fed details. I work (hobby) with processors from <2Mhz to the big multi core, GHz stuff.

        Yes, I think this is the same low end single core processor as the Pi 1. Also no FP in the processor so best to work with integer math as much as possible.

        Doesn't Python do something weird and convert all numbers to floats?

        Still I would venture a guess that the Pi W is faster than the ESPs. Still not as cheap as some of the ESPs but at $10 (US) it beats a lot of the ESP based boards.

        1. Neil, SBCs and microcontrollers are total different beasts... MC use a single "program", often called "sketch" these "arduino days", and needs recompile and reinstall firmware to change even a bit... just to simplify...

          SBC use a COMPLETE operating system, and as such are multitasking, but these has the drawbacks of them being slower on boot (the OS has to start, all the services too, even the one you human use, like webmin, but are useless when the device is independent...), almost always this OS is on a "prone to fail" sdcard (just a bad reboot for power loss can make them unbootable), and so on...

          the fact that the PI0W and, let's see an esp8266 board variant, like the nodemcu, have quite the same physical size, doesn't make them interchangeable...

          the way we use these boards, as Peter is trying to "teach" us, is having a SBC controller which collects data from and send commands to many little boards around... i find this paradigm, or pattern, ideal for IOT, while having full SBC lying around (just because they're small, cheap, and more powerful), well, no...

          1. The problem I have with "it's too slow" comes from people at our maker space. One gentleman wrote code in a language he didn't understand (Python) and complained that the Pi 2 couldn't keep up.

            When I started SBCs were microcontroller boards. 🙂 Still have a few of them (s180, 8052 & AVR before Arduino). I won't argue with the little devices on the outside, bigger devices at the core.

            I have Linux at the core of my network. I've had 8052 and PICs as the remotes (via RS485) and a S180 board (Steve Ciarcia's HCS II) doing the controlling but with networking the S180 board's functionality is being handled by a Linux server. But the Pi W gets to be an interesting board in that I can throw together a high level language at a problem and write and debug much quicker than I can with an Arduino or ESP. Also adding things like ssh and TLS make securing the device a lot easier. Pi W (~$10) vs ESP-12e (~$7) is very close. Of course where I need a cheap terminal server the ESP-01 (plus flash upgrade) beats the Pi W.

            We live in much more interesting times now and I love this stuff.

    1. Hi there Neil.

      Ahem, when i was a kid - apart from working 25 hours a day down the mine...

      We had zilch. As I left school, the only computers available meant going along to the university, If you were privileged enough to be on a course which I wasn't, with a large pile of cards, in which one mistake meant going back to the drawing board. In my early teens I built a valve amplifier - which was horrible and dangerous... and my first introduction to little computers was the Sinclair Mk 14 which didn't even have a proper stack, it had an "auto-incrementing register". Best I could do was scroll my name across the display. I soon got rid of that and bought a kit for the "NASCOM" - which had a Z80. I hand-entered Bill Gate's "5K BASIC" and shortly thereafter bought the K&R C book and the rest is well known.

      I want a Pi Zero Wifi - with 4G RAM, an octal processor and 16GB of emmc - for £5. I probably won't have to wait too long 🙂

      1. Pete, I think we're of the same age. I may be a bit younger. I recall dropping my first deck and learning about numbering the cards. I worked on cars and migrated to electronics. Read up on everything computer in Byte magazine and a dozen other magazines in the College's library. Started the college's computer lab (Apple IIs and IBM PCs, DOS 1). Worked on PDP8s, Burough's Mainframe, and an 8085 SDK board. Man, what we've seen and gotten to play with has been fantastic. But I like my newer toys better. Can't wait for the Pi 012 W 😉 Hope it can be solar powered

      2. Crikey, another nascom user here. Had a nascom2 and did lots of hw and sw mods to it. Sold it for more than it cost.... That's a rarity for computers!

        1. Hell - I had mine attached to an S100 bus, and disks, running 32K structured Basic (or was that the Exidy Sorcerer, might have been the latter thinking about it) - sold it for enough to buy a second hand car!!

          1. Sorry for the late reply (and possible timewasting!). I was looking for something else and saw the word "Nascom"..... Had a 1 and 2, eventually running CP/M with twin 8" disks (very secondhand). Unbelievably 40 years ago. I just had to google it and found http://www.nascomhomepage.com/ still active and looking for archive material. I also remember paying £406 for an Epson dot matrix printer in 1979 - what would that be in 2017 money........

            1. You know I just do NOT remember the Nascom 2. I built my Nascom from scratch... and I remember putting BASIC on it....and it having a nice keyboard... I do note there's an emulator for it on that site.... The printers now, like much of that stuff - if brought to today's prices would be horrendously expensive - I don't know how we found the money.

  3. Anything can be solar powered if you have a big enough solar panel 🙂

    I've just had delivered a little back-pack for the Pi3. It mounts on the back (I have a small LCD touch screen mounted on the front) and has a 3800MaH battery. I plan to use this as my main controller in Spain where the electricity supply is "iffy".

    A solar panel - with a 28v to 5v convertor will power the backup supply board - but then it IS a 250w panel 🙂

  4. Hi Pete, well now I know a second person who had a Sinclair MK14. Started with just the board, increased the Ram to 512Bytes. even added the TV interface, which took a while before I realised that Sinclair had fitted a colour burst crystal and not the 3MHz shown and required for the tv interface.

    bring back the moon landing or duck shot games.

    Now I'm feeling old *-(

    1. Oh I'd forgotten how little RAM those things had - not that you could use much of it with no proper stack. And now you remind me of trying to do very simple graphics on an old TV with those things.... front porches, back porches, flyback - well, we're way off topic here but interesting times.

      As well as the MK14 I also had Sinclair's Executive calculator (the thin black one) and the other one you could only use in reverse polish (remember 10 10 + = which actually still makes sense to me)

      What gets me is the cost - those things were not cheap in today's money - but accounting for inflation, I must've spent a LOT of money on those early computers. The sad things is - here we are in 2017 and I can still remember the major op-codes for the Z80.... how sad is that. Not that I EVER want to go back to machine code or assembly, I'm very happy with Javascript and C thank you.

      1. " ... and the other one you could only use in reverse polish (remember 10 10 + = which actually still makes sense to me)"

        I have the HP28 emulator on my phone, I have a command line HP28 on my Linux boxes (Pis included) and probably can't use a normal calculator without a whole lot of thought. 🙂

        1. Reversed Polish notation, yes I remember that very well. I already had trouble with normal polish let alone reversed. I fiddled with building my own computer based on a 6502 in which i had to enter machinecode with a few buttons.... yes, still remember the upcodes.

          25hrs/day working down in the mine, you had it easy, I had to work double shifts and that was just before i had to walk to school, on bare feet, through the snow, even in the summer

            1. I'm great with foreign languages, assembler, C, Perl, Python, Fortran, ... 😉

              If it has a network and automation I can order the beer anywhere in the world. Delivery is a bit problematic though.

  5. AFAIK, the latest link about "ups idea", the item is limited to 1A, so it should be even worse of the one you put on the back of your rpi3...

    you should test these things with a dummy load, to see what they can really deliver about power...
    https://it.aliexpress.com/wholesale?catId=0&initiative_id=SB_20170312033909&SearchText=carico+usb

    the 35W with oled display is cool, but for that price is MUCH better taking the big 60W version, which you can use for everything, not just usb/5v:
    https://it.aliexpress.com/item/Constant-current-electronic-load-Discharge-9-99A-60W-30V-battery-capacity-tester-Free-shipping-with-tracking/32546800281.html

    the 60W dummy load is well tested on youtube and recommended, take a look at voltlog's review and teardown
    https://www.youtube.com/watch?v=snROh2acybs
    https://www.youtube.com/watch?v=KYncNH8_m70
    https://www.youtube.com/watch?v=K-7kgfbH-eI

    Andreas Spiess reverse engineered the protocol, and substituted the 7sec display with a nextion, very informative videos...
    https://www.youtube.com/watch?v=vfwXjWtNxqY
    https://www.youtube.com/watch?v=18Ew5_r17AA

    if you want to go cheap, then this couple will do the job
    https://it.aliexpress.com/item/15W-RD-Industrial-Grade-Electronic-Load-Resistor-USB-Interface-Discharge-Battery-Test-Meter-Adjustable-Capacity-with/32764940443.html
    https://it.aliexpress.com/item/Digital-Dispay-3V-30V-Mini-Current-Voltage-Charger-Capacity-Tester-USB-Doctor-QC2-0-quick-charge/32616678486.html
    https://www.youtube.com/watch?v=OyenTwclA8Q

      1. Mr. Shark, thanks for all the links. I'll need to take a good look at that later. The maker space I belong to is part of a larger space (InfoAge in Wall, NJ) and they'd like to see a lot more science exhibits. A nice alternate power demo would be something that go along way towards InfoAge's charter. It won't be the only one.

      1. Ah you did it wrong then!. Docker is an amazing technology - i have 23 containers running on my media server and it doesn't miss a beat. Try again. You won't regret it.

  6. I own a ups-pico and unfortunately it is garbage. It drains the battery to zero volt. Charging the battery was also not done very well. Setup was troublesome. It tried to use it with my rpi-2. You can have mine if you want it.

    1. Well now that IS interesting! I wonder if it is a bad design or just a one-off - same of course with the board I've just mentioned in here. A shame. Still - there are other solutions but one that mounts on the back of the Pi etc is just so convenient - no good if it doesn't work though.

      1. Whaaa? I admire that it can be done, but what would I use node-red on a smartphone for? I'd love to hear ideas.

        1. Well, Kris - I have in front of me an otherwise useless Oukitel K10000 - yes, that's the battery size. The screen is bust... as of now it is busy installing my script via SSH - so...

          IF it works and can be made to reboot automatically, that makes for a very powerful home server with many hours of proper battery backup - oh, and sound, maybe... and camera, maybe....

        2. as said by Peter, it is A LOT faster than any SBC, has 1 or 2gb ram, has 8 or 16gb emmc (no crappy sd cards...), has a battery which lasts even a day (as i don't plan to use the screen, but even with it, there are HOURS of activity...), and the battery can be charged WHILE you use it (PSU problem: solved!)...

          not planning to go around with a portable node-red (just because i have not even thought if useful, for now there's too much nerdness in me to think to these uses), but to have a spare smartphone lying around again useful, with a new life... 1st principle of hacking: why doing something? Because you can... 🙂

        1. Not a lot of use on it's own.... to be useful it needs to be on from powerup - along with the likes of SQL and MQTT... Getting Linux running properly on an old phone is actually a cracking idea.

            1. That deserves a round of applause - seriously well done there!

              I'm not entirely sure this is "full fat linux running on smartphone bare metal"..it feels more like "linux running on top of/inside android".

              Still a nice achievement though 😉

              1. well, it is a chroot environment, so the latter is correct...

                my purpose was not to install linux on a smartphone (which sure i prefer...), but to have the easiest way to put the full stack Peter's script creates, on a device which should be fast (sure faster than many SBCs, even if only because of the eMMC instead of SD...) and with a PSU like function (smartphones can be charged while in use, unlike most powerbanks...), and a touchscreen!

                all you need is a rooted (this is required...) smartphone, with an app freely available in Play Store, download a premade Debian Jessie image, set the chroot as you will see in next days, and run Peter's script... done! Any rooted second hand smartphone will do the job, everyone could have one of this lying in a drawer...

                and I think we can even export a premaid rootfs with all already setup, just to import! Are there better ways? Sure... easiest, with all the features i wrote? I doubt... Peter has details in his email, I think tomorrow a new blog article should clarify everything... 😉

        1. mine too, then i pressed CTRL-C, and made
          cd .node-red
          node-red

          it started, and then i pressed again ctrl-c, and now i had my settings.js... i followed the remaining node-red script part manually, and then went on with the remaining...

          anyway, on reboot it was gone, as i didn't save the state... i need to retry but i need time, the other app is not as efficient (starts in GUI, don't like this...)...
          looking for a way to have this stable, or other apps...

          main problems: autostart this app on phone reboot, and worst, autostart it's linux and it's services on reboot...

    1. have faith (in root we trust!)... 2 hours ago this was not even on your mind 🙂

      now we need only to have it stable (saving its state and maintaining on reboot), and a few alteration to the script to bypass the start stop restriction as systemctl cannot work in a chroot environment... and, this is only the first app tried, which needs only a smartphone with root access... there are other options 🙂

      just the fact that, for a few minutes, i had node-red, apache, mqtt, running on a smartphone, is impressive... a nerdgasm 😀

      to be continued... 🙂

  7. Once upon a time a couple of years ago I had full Debian running on android. LXDE worked fine and I managed to get TightVNC going on there too. I guess it can sort of smooth the path for some stuff rather than trying to run on bare android.. The novelty wore off for me though

    1. "yos and ne" 🙂
      that would be ideal and as a penguin i'll prefer that... but how can this be smooth for people used to use windows on their pc, and worst, that could not even have root on their phone?

      Imagine to deal with hordes of people, with all the infinite variants of smartphones with android, not all rootable, much less of them even with a proper recovery from which to install an other rom/os... a poker of 3 with the death.... instead, having an app that runs on top of android, is MUCH easier...

      but main concern for now is how to autostart the app, which is doable, but how to autostart the linux inside the app itself... well, the fun has still to begin 🙂

      the easiest path could be an intel smartphone/tablet, for your way, i think...

      1. haha I hear you, I'd much rather not have to deal with hordes people with a ton of different platforms and ideas. That'll be why I'm a developer in my day job who doesn't have to talk to end users..there's just business analysts and project managers who need to be kept happy..oh wait 🙂

  8. Pete, just two quick notes since I also test through RPi Zero W currently (interested in video camera application connected to usual servers through g_ether module).

    I did some tests with 'el cheapo SBC Wi-Fi' comparing RPi Zero W, NanoPi Air (same Wi-Fi chip inside), Orange Pi Lite (best single antenna Wi-Fi), Pine64 (same Wi-Fi/BT combo as the CHIP) all with same antenna under same conditions. And a dual antenna crappy Wi-Fi USB dongle (that can shine in crowded areas due to the 2nd antenna since MIMO and antenna diversity then do the job):

    https://forum.armbian.com/index.php?/topic/3739-wi-fi-performance-and-known-issues-on-sbc/

    Also some notes to get the Zero W up and running headlessly with Raspbian Lite (SSH needs a small hack, enabling g_ether mode to login without keyboard/display another): https://forum.armbian.com/index.php?/topic/3676-raspberry-pi-zero-wireless-rumors-speculation/&do=findComment&comment=27175

    1. Oooooh right I'm off to have a look - they gave me a refund as the board was utterly and completely useless - I MAY have brought it to Spain with me - if so that would be really useful....

  9. Thank you for sharing this page.
    I've been trying to get my pi zero w going with reliable wifi and nothing seemed to work. I found you page and Dietpi (also never heard of it) and walla everything works!!
    Also thanks for sharing your script, it worked excellent.

  10. Dear Peter,
    thank you soo much for your shared informations on this site.
    I have a problem and i hope you can help to fix it.
    Andeas Spiess inspired me to use your Node Red script for setting up a home automation system. Unfortunatly i,m a linux newbe a have no idea.
    My MQTT Thing is not connecting to NODE RED. I tested it with cloudMQTT and it works fine. After investigate a bit i find out that Mosquitto is not run probably.
    mosquitto -v brings the following result:
    1498105665: mosquitto version 1.4.11 (build date Mon, 20 Feb 2017 22:47:27 +0000) starting
    1498105665: Using default config.
    1498105665: Opening ipv4 listen socket on port 1883.
    1498105665: Error: Address already in use

    Stop and restart Mosquitto does not solve it.
    Restart the Raspberry does not solve it.
    What do you think i should try next?

    Thanks a lot

    Thomas

  11. Thanks for your suggestion regarding using mosca.io.
    I think testing that would bring me to new problems.
    As i mentioned before am a totally beginner in linux and habe no clue how to fix the error.
    What can i test to got it running with mqtt?

    Thanks a lot

    Thomas

  12. Hi Peter,
    Tried your script on my Orange Pi PC2. It ran into a wall when trying to download Mosquitto. I think it is due to that I am running 64-bit DietPi on it, and it seems there are no ready built ARM 64-bit Debian packages of Mosquitto.

    Perhaps a test in the script that only 32-bit Linux (on ARM) is used.

    I am going to try and build an ARM 64-bit version of Mosquitto, but I am missing a changelog file at the moment, and possibly other files as well.

      1. I realized that the special handling of mosquitto was unecessary. So I commented out the lines handling the installation of mosquitto differently when the condition OPSYS == UBUNTU is not true. Then I removed the /etc/apt/sources.list.d/mosquitto-jessie.list file created in a previous run. Now the installation completed. I can connect to and log in to node-red now. Haven't added anything yet, but it is looking good so far.

        I am not sure why Ubuntu and Debian are treated differently in the script. After all both Ubuntu and DietPi are derived from Debian.

        These are my observations from using the script. Please take them for what they are. I am not complaining, just letting you know what I saw. I am grateful for the time I saved not having to put it all together myself.

        The text colouring is rather annoying. I normally have a bright off-white backround colour in my terminal window, and black text. So when the script changes the text to a colour similar to the background - it is really hard to make out what is printed.

        The script does not seem to respond to ctrl+c. At least not all the time.

        When an error occurs it isn't really handled. The script continues executing.

        In my case when the command "npm" was not available (due to failed mosquitto install) the script seemed to go into some form of loop and never finished. I had to send a kill signal from another session (since ctrl+c wouldn't work).

        1. A couple of quick comments - colours - defined at the top - your case of having a while background may be unusual - no-one has mentioned this before - anyway the solution is to change the colour defines at the top.

          Errors - yes error handling could be better - I'm waiting for some enterprising Linux-type to go through and make it bulletproof - it would take me too long given my limited script skills - and Antonio and I spend more than enough time making changes to the script for changes in the world - right now he's working on Debian 9 ! As it is source there is nothing to stop anyone offering better ways to do it.

          We'll check that npn issue... not something I've come across. Ubuntu and Debian may well have a common base - but trust me - they're not totally compatible - we certainly didn't put in those distinctions for fun 🙂

        2. your assumptions are wrong...

          ubuntu WAS based on debian, ages ago... now they're not compatible anymore, each took a different path...

          ctrl-c: never do that... if script is installing something via apt or similar, you can end up with a broken system... better waiting completion...

          i did most of the error handling stuff, and yes, more can be done, more i added this morning, but can't predict every single case... yes, script goes on, what did you expect, begging for solutions? Reports what's wrong and we'll try to fix it... run script WITHOUT the QUIET option for more info...

          npm and mosquitto are 2 different beasts, not related in any way...

          more error handling is on the way, as i spent quite the full morning to add support for Debian 9 (Stretch) to the script, for now tested only in a VM as no other SBC distro is updated to it, yet

          1. Use trap command in the script to catch ctrl+c and other keyboard interrupts. Or pass it on to whatever command is executing.

            Check exit code from previously run command with $?

            Enable script abort on error option with set -e

            You may want to tee both stdout and stderr to a log file.

            Just my suggestions. APT and other commands that are part of the distribution and manipulate the installed packages are perfectly capable of handling keyboard interrupts.

            There is still some Debian in Ubuntu. At least there is still a file named /etc/debian_version on the Xubuntu/Jessie machine I am typing this message on. And as you noticed APT is still very much in use on Ubuntu and you can install .deb packages. Debian seems to still consider Ubuntu a Debian derivative.
            https://www.debian.org/misc/children-distros#ubuntu

            Using ANSI sequences directly to manipulate the colours is dangerous in my view. You don't know what type of terminal the user uses to connect to the system or how they have configured it. Sure in 99.9999% of the cases it is a standard terminal window, or PuTTY or something like it that understands ANSI escape sequences by default. Instead you should use the tput command to manipulate the terminal foreground and background colours, which should always work provided that the type of terminal is correctly set.
            https://www.gnu.org/software/termutils/manual/termutils-2.0/html_chapter/tput_1.html

            By the way, I haven't configured Terminal in Xubuntu. It comes with defaults set to off-white background and black foreground.

                1. Erm, save me a little research.. tput only does colours 0-7, and it does dim which would give 0-15 - but I can't seem to catenate the two on one line? Example? Dark green?

                  1. You realy have to check on which console you are.
                    >> echo "$(tput bold)$(tput setaf 2)$(tput dim) ###########"
                    This example works on Debian-Stretch (starting to gui) in a terminal, but it does NOT work via putty 🙁
                    "bold" and "dim" will be ignored.

                    You can also use RGB, but also not via putty... *sniff*

  13. Hello Peter,

    after a lot of testing i have a clue on why mosquitto is not running on my system.
    After a fresh install it works fine. But when i activate WLAN and deaktivate ordanary LAN it doesn't work anymore. So it seems Mosquitto has a binding to a certain network interface. Can you confirm that, and if yes, how can i change it?

    Thanks

    Thomas

    1. Thomas - unless your Mosquitto is very different to mine I can't agree with that summary - I've swapped in testing from WLAN to LAN many times and Mosquitto has never failed. Indeed the only time it has failed and even then it was only the startup script - was with LOG2RAM... let us know how you get on with this...

  14. Hi, im realy frustrated. I didn catch it. I tried several hours to invetigate whats going wrong but no clue. LOG2RAM istnt installed. The only thing i didt was to install Andreas Spiess image. I think you know him because i saw i few comments from you in his Videos on Youtube. When i use the immage and change the ip adress for the Lan Interface to my Routers Range it works. But when i deactivate it an enable WLAN, which is successful because i can connect via webinterface mosquitto is not any longer running probably. I also tried it with both interfaces activated. This is the only change i did to the clean immage. I ran it on a Raspberry Pi ZeroW.
    Any additional hint what i can do?

    Thanks a lot

    Thomas

  15. Hi, i hope i dont annoy.
    I Try now to run the script.
    pi is created and logged in
    chmod 0744 to script.sh is done
    bash scrpt.sh brings some errors
    See attachment.
    What have i to do now?

    Thanks

    Thomas

  16. Thanks, this worked. Now the script aborts because i try to run it from boot folder.
    It writes that i have to start it from home/pi folder. Unfortunatly i created pi without homer folder. I created it afterwards and now it seem that i habe a problem with user rights. I try it again from the begin and than i backup the clean immage!
    Next week i've got a bit more time because my wife and doughter are on vacation

    1. if you're on dietpi, you have just to run the script as root, nothing else...
      that will create the pi user in the correct way, then you login as pi user and rerun the script, which will be already there waiting for you...

  17. Dear Pete,

    I have a raspberry pi 3 configured as AP using (hostapd and isc-dhcp-server) + mosquitto server. I tried to connect around 70 sonoffs, unfortunately only 32 can
    connect at the same time. The DHCP pool is large enough. Hostapd maximum clients is 200 (default value). Do you have any suggestion where is this limitation coming from ?

    Sorry if this is a little bit off topic.

  18. hi,

    Why did you replace the DietPi versions of SSH and webserver with "heavier" versions in this setup?

    do these versions not work with The Script?

    regards

    Glen

Leave a Reply

Your email address will not be published. Required fields are marked *