Concussion and Arduinos.

Advert

Concussion and Arduinos.

Home Forums The Tea Room Concussion and Arduinos.

Viewing 25 posts - 1 through 25 (of 27 total)
  • Author
    Posts
  • #746049
    Robin Graham
    Participant
      @robingraham42208

      It’s been ages since I posted on this forum at least in part because of an incident involving a flight of stairs, a flowerpot and my head.  The stairs and the flowerpot are just fine but five months later I’m still convalescent. I hadn’t realised how generally debilitating minor brain trauma can be. That’s the concussion bit…

      I’m still not confident using machinery, hence the Arduino bit. I’ve been tinkering with the things as a way of keeping myself occupied. What I’d like to do is to use an Arduino (or ESP) to control/monitor stuff and communicate with my (Linux) PC over my home network.  I don’t want anything fancy like setting up an HTTP server , TCP/IP or even UDP would be fine. But it’s proving difficult to find example code of how to do this in the Arduino world.  I’ve tried posting on the Arduino forum, but no dice so far.

      Has anyone here got something like this working?  I’m OK with the Linux end of things, it’s the microcontroller end that I’m having trouble with.

      Robin.

      Advert
      #746064
      John Haine
      Participant
        @johnhaine32865

        Sorry to hear about your accident Robin, I hope you continue to make a good recovery! I assume that you have discovered the arduino forum? There’s a lot there about such projects though some dross filtering is needed! Lots of code posted on github too.  But you could also look at the Raspberry Pi ecosystem, the Pi Pico is much more capable than most arduinos, can be programed in C or Python, and there’s loads of code available.

        #746093
        SillyOldDuffer
        Moderator
          @sillyoldduffer

          Poor you Robin!   I’m 4 months into a gastro/intestinal problem, always mildly uncomfortable and often downright painful.  Taken all the fun out of life, can’t concentrate etc.

          Anyway, to connect an Arduino to Ethernet, you need:

          • An ethernet2 shield – example £28 from Farnell.  Plugs into Uno, Mega etc.
          • To install the Ethernet2 Library (easily done from the IDE)   It comes with examples: have a look at UDPSendReceive.ino,  WebClient.ino, and WebServer.ino  From IDE File->Examples->Ethernet2->
          • And something for these programs to talk to.

          Although UDP & TCP/IP might seem simple, probably easier to implement this with HTTP because the library hides a lot of set-up code that UDP & TCP/IP expect the programmer to provide.  Also easier to find HTTP server examples.

          Hint: after familiarising myself with the examples I would start the real job by implementing the control/monitor code with the Arduino connected by USB serial.   Serial is straightforward and well documented.   Only after having got the control/monitor part talking to the PC, would I upgrade to HTTP, effectively replacing the Serial library calls with Ethernet library calls.   The code is similar.   Divide and conquer  rather than trying to solve everything in one go.

          Happy to help with specific questions, Arduino or Linux.  I’d do the Linux end with Python cos it’s easier if if you know Python, but I’m OK with C or C++ too.  I don’t have a ethernet2 shield yet – tempted to order one, but I do have an unboxed ESP.  ESP are faster than Arduino’s and have built-in ethernet wifi, but fewer general purpose IO pins that operate 3V logic, and are electrically a little more delicate.   In principle, much the same as an Arduino: install the ESP platform, then look at the ethernet API. Not tried it yet!

          Dave

           

           

          #746096
          John Haine
          Participant
            @johnhaine32865

            I believe ESPs also have proper security features should that be important.

            #746118
            SillyOldDuffer
            Moderator
              @sillyoldduffer
              On John Haine Said:

              I believe ESPs also have proper security features should that be important.

              Good point!  I assumed that Robin’s project was internal, running on his home network and not connected to the internet.   If so, the necessary security is physical, that is someone has to burgle the house to gain access.  An Arduino is usually OK for that.

              An ESP comes with features that protect it when the micro-controller is open to the internet, that is connected such that outsiders can access it without breaking and entering.  Not a free lunch – the security features aren’t enabled automatically, so more work for the programmer.  Later ESPs are better protected than older ones.

              A basic Arduino application might be acceptable on the internet, but the design would have to be locked down good and hard, rigorously removing functions, and making sure the code has no loopholes.  Not too difficult on small simple applications, but liable to become off-the-scale difficult with rising complexity.

              Dave

               

               

              #746181
              duncan webster 1
              Participant
                @duncanwebster1

                You can communicate twixt Arduino and mobile phone by blue tooth, so I’d be surprised if you couldn’t talk to a PC that way. Just a possible alternative

                #746329
                Huub
                Participant
                  @huub

                  I use an ESP8266 to communicate (serial connection) with my PC and my grbl controller. Here you find the example code and description. For ESP(32) developing I switched to the ESP32-S/ESP32-C3 because they have a built-in JTAG debugger that uses the USB connection.

                  I also use Bluetooth for the same purpose. This is also described in the link.

                  #746341
                  Robin Graham
                  Participant
                    @robingraham42208

                    Thanks for replies.

                    On John Haine Said:

                    Sorry to hear about your accident Robin, I hope you continue to make a good recovery! I assume that you have discovered the arduino forum? There’s a lot there about such projects though some dross filtering is needed! Lots of code posted on github too.  But you could also look at the Raspberry Pi ecosystem, the Pi Pico is much more capable than most arduinos, can be programed in C or Python, and there’s loads of code available.

                    Thanks. Yes, I’ve discovered the arduino forum, and you are right about the need for filtering!  I’m at the stage with this where I keep following leads/links and end up with 50 browser tabs open and lose track of dead ends/possibly fruitful paths.  I’ve also looked at github – there seems to be some variability there too, some code has useful documentation, sometimes it’s a matter of looking at the source and figuring out how it works.

                    Someone on the Arduino forum also pointed me towards RPi.  I have a 3B but a bit of an overkill for what I want to do, but maybe maybe Picos would be good. Shall investigate further!

                    On SillyOldDuffer Said:

                    Poor you Robin!   I’m 4 months into a gastro/intestinal problem, always mildly uncomfortable and often downright painful.  Taken all the fun out of life, can’t concentrate etc.

                    Poor you too Dave! My wife developed GI problems (Covid? – lots of weird after-effects reported) and they knocked her for six. Diet (ie total abstinence from anything remotely tasty) has helped a lot in her case.

                     

                    Anyway, to connect an Arduino to Ethernet, you need:

                    • An ethernet2 shield – example £28 from Farnell.  Plugs into Uno, Mega etc.
                    • To install the Ethernet2 Library (easily done from the IDE)   It comes with examples: have a look at UDPSendReceive.ino,  WebClient.ino, and WebServer.ino  From IDE File->Examples->Ethernet2->
                    • And something for these programs to talk to.

                    Although UDP & TCP/IP might seem simple, probably easier to implement this with HTTP because the library hides a lot of set-up code that UDP & TCP/IP expect the programmer to provide.  Also easier to find HTTP server examples.

                    Hint: after familiarising myself with the examples I would start the real job by implementing the control/monitor code with the Arduino connected by USB serial.   Serial is straightforward and well documented.   Only after having got the control/monitor part talking to the PC, would I upgrade to HTTP, effectively replacing the Serial library calls with Ethernet library calls.   The code is similar.   Divide and conquer  rather than trying to solve everything in one go.

                     

                     

                    Thanks for suggestions.  I want to use wifi rather than ethernet, but your comments still apply.  I had thought avoid HTTP because it just adds another layer of complexity – until recently at least it’s an application layer based on TCP if I understand things correctly.   So I thought TCP should be simpler, but you’re right there are a lot of HTTP examples out there.  Maybe that’s the way forward.

                    You are correct in thinking this is all on ‘my’ side of the router, so security shouldn’t be a problem.

                    ______________________

                    Thanks for other contributions too, much appreciated.

                    Robin.

                     

                    #746354
                    John Haine
                    Participant
                      @johnhaine32865

                      It’s probably worth noting that what you want to do could be generally described as “internet of things”.  There is a whole raft of IoT communication protocols that has been developed – Google the emboldened words.  One for example is MQTT.  These operate at a higher level than things like HTTP and TCP and exist to overcome the disadvantages that those protocols have for embedded devices and constrained communications.  There’s also a lot of software around to implement them.  Most industrialised IoT solutions these days would use this approach.

                      Comparing Arduino and Pi Pico, the PicoW (with on-board WiFi and Bluetooth & 2 ARM cores) can be had for £5.80 whereas a genuine Arduino Nano which has neither, less memory, and one rather old processor core is £22 (clones are available).  The Nano is probably easier to use (at first) and only has 3.3V I/O.  I’ve been using Arduino exclusively but future projects will definitely use the Pi.

                      #746358
                      SillyOldDuffer
                      Moderator
                        @sillyoldduffer

                        There’s a book to be written comparing the pros and cons of the various microcontrollers available.

                        Briefly:

                        • Arduino’s are beginner friendly, electrically robust, and extremely well supported with software libraries and plug in modules.  Strong on General Purpose IO, and OK for protocols like I2C and SPI etc.  They are relatively slow, don’t have much memory, and have to be programmed in C (actually sawn-off C++).   C would be a serious obstacle were it not for the Arduino IDE which does an extraordinarily good job of hiding the complexity of the underlying tool-chain.
                        • Though improving, Picos are less well supported than Arduinos.   They’re inexpensive, have two fast processors, plenty of memory and some interesting peripherals.  Pico W and Pico WH have built-in Wireless Ethernet and Bluetooth, bit fewer IO pins.  Pico are programmed in either C/C++ or MicroPython.    The latter is beginner friendly, but C/C++ is proper grown-up.   A simplified C/C++ environment is available for the Arduino IDE, but don’t expect Arduino libraries to ‘just work’ on a Pico.   Easier to learn and write MicroPython than C/C++. but the result will execute relatively slowly and consume more memory.   Performance probably not a problem in Robin’s application.
                        • ESPs are fast processors, with built-in wifi.  Not got into them in detail, but fairly well supported.   Main disadvantage is the smallish number of IO pins available.
                        • STM Nucleo are another option, fast processors, loads of pins, several boards.  Mostly programmed in C/C++,  and on the grown-up side rather than beginner friendly.

                        When choosing one, it’s important to consider how easy it will be to program.   Very often microcontrollers are connected to a peripheral, and the last thing a beginner needs is to find he has to write the interface code himself!  Interfacing to an unsupported peripheral is not beginner  work!  Far better to use a microcontroller for which a documented library already exists, ideally supported with tutorials and forum info.  This is where Arduino generally has an advantage.

                        That said, this Pico example isn’t a million miles away from Robin’s requirement.

                        Dave

                        #746363
                        duncan webster 1
                        Participant
                          @duncanwebster1
                          On John Haine Said…………. The Nano is probably easier to use (at first) and only has 3.3V I/O.  I’ve been using Arduino exclusively but future projects will definitely use the Pi.

                          The ones I’ve been using have 5v I/O, admittedly clones, and they cost a lot less than £22

                          #746365
                          John Haine
                          Participant
                            @johnhaine32865
                            On duncan webster 1 Said:
                            On John Haine Said…………. The Nano is probably easier to use (at first) and only has 3.3V I/O.  I’ve been using Arduino exclusively but future projects will definitely use the Pi.

                            The ones I’ve been using have 5v I/O, admittedly clones, and they cost a lot less than £22

                            Sorry, I meant 3v3 for the Pico.  Yes, I always use Nano clones too, I was just comparing the official prices of the two products.

                            #746650
                            Robin Graham
                            Participant
                              @robingraham42208

                              Thanks for further replies. The mists are beginning to clear. Somewhat.

                              I do have some prior knowledge in that I bought a box of Nano clones (Elegoo) a year ago to use in panto props, but it was pretty simple stuff – just turning lights on and off.  The boards were ~£5 apiece, and played fine with the Arduino IDE.

                              This project is to resuscitate a fridge – the control system has failed in a way that causes the compressor to run continuously. So I thought I’d build a new control system, and why not measure temperature in different regions of the fridge and make a log too, because that would be fun.  So I bought some temperature sensors, SD card module &c and have all the components working individually using nanos and a mix of core / contributed Arduino IDE libraries.  Then I thought it would be neat to send the data to my desktop via LAN, which is where my present confusion began.

                              John. Thanks for the pointer to IoT protocols. I’ve had a first look and it’s interesting.  At the moment what I’m envisaging is a controller in the fridge which stores data locally and responds to a “what have you got for me?” request from the desktop PC with a data stream. The other way round the PC sends a request saying it wants eg the set temperature changed, and the controller complies. So the PC is always the client. I think that can be done with HTTP?

                              Dave. Thanks for your useful summary.  In my case I’d (sort of) rejected the RPi path because I don’t have much Python and anyway it seemed crazy to using an interpreted language running on a microcontroller.   On the plus side though, RPi do seem to have a very well documented C SDK – just not as many ‘oven ready’ C libraries for peripherals.  I now have an ESP32-S and likewise Espressif have a well documented C toolchain, but much more complicated to navigate than the Arduino IDE. Hmm. May PM you if that’s OK as this could get too long for something of perhaps limited interest on this forum.

                              I’ll almost certainly get hold of a PicoW – in the light of comments it seems likely to be the better way forward in the long run.

                              I hope it’s obvious but before anyone tells me to just buy a b****y fridge, this is more journey than destination!

                              Robin

                              #746666
                              Michael Gilligan
                              Participant
                                @michaelgilligan61133
                                On Robin Graham Said:
                                […]
                                I hope it’s obvious but before anyone tells me to just buy a b****y fridge, this is more journey than destination!

                                It is indeed obvious, Robin … and I wish you a good journey.

                                MichaelG.

                                #747600
                                Robin Graham
                                Participant
                                  @robingraham42208
                                  On Michael Gilligan Said:
                                  On Robin Graham Said:
                                  […]
                                  I hope it’s obvious but before anyone tells me to just buy a b****y fridge, this is more journey than destination!

                                  It is indeed obvious, Robin … and I wish you a good journey.

                                  MichaelG.

                                  Thanks for that wish Michael.  It is certainly an interesting journey and at last, after visiting many cul-de-sacs, I am beginning to see some open road.

                                  I delved a bit deeper into the RPi world and was impressed by the documentation. Although there’s a lot  (possibly too much ) out there about Arduinos much of it seems unclear to me. So I bought a couple of Picos.

                                  Because I’d prefer to use C/C++  my first recourse was to Rpi’s C/C++ development guide . The recommendation was to use Microsoft’s Visual Studio Code. That didn’t work out well for me perhaps because I’m using a Linux machine.  I don’t know. It became a sort of software Hydra – every time I fixed one problem two more appeared. Then I found Lief Koepsel’s blog .  He explains how to install all the necessary links in the tool chain then build a binary and install on the Pico from the terminal. It just worked.  He also covers Windows and MacOS I think.  He writes on many other related topics as well – a valuable resource for anyone interested in this stuff.

                                  The moral of this sorry tale is obviously to avoid terracotta flowerpots wherever possible.  Plastic versions are available. Or live in a bungalow.

                                  Robin.

                                   

                                  #747622
                                  John Haine
                                  Participant
                                    @johnhaine32865

                                    I’m glad you’re making progress Robin.  And thanks for the link to Lief’s blog – it looks very useful.

                                    #748950
                                    John Haine
                                    Participant
                                      @johnhaine32865

                                      Just to add, I found this yesterday:

                                      https://randomnerdtutorials.com/programming-raspberry-pi-pico-w-arduino-ide/#Raspberry-Pi-Pico-Boards-Manager

                                      I have just followed the procedure there to install the Pico 2040 to the Arduino IDE and it was trivial.  Not tried programming yet but looks promising.  Being pretty familiar now with the Arduino this looks a good way forward.

                                      #748972
                                      Joseph Noci 1
                                      Participant
                                        @josephnoci1

                                        Robin,

                                        A very quick way of doing this is to use Node-Red –  a free install on PC and Linux, which is a graphical programming tool. There are thousands of user written ‘nodes’ which you can download and use to create the flow diagram for your application. You then place display nodes ( gauges, graphs, bar charts, etc) on a display page, and the data is displayed as you want. You don’t need to know C, Python, Cobra, or any language if you don’t want to, although Java script can be useful but I don’t need it..My house automation, solar system, weather station, underfloor heating and Alarm is all controlled via node red. I use ESP32’s all over – they link via wifi, using Mosqitto as an MQTT server, running on the same pc as the node red. Coms tween esp32 and node red is very easy and there are dozens of open source nodes out there to do anything you could want. Very powerful and very simple.

                                         

                                        This is a sample image of the display page of the weather station – also shows the status of the lights in the house – they are automated to turn on/off randomly at night when away, etc

                                        node-red WX

                                         

                                        This shows the node red nodes that implements the display page above

                                         

                                        node-red WX nodes

                                        Of course you have to write the code for the esp32 itself, and I do that all in the Arduino IDE using the esp32 extensions – easy as pie ( NOT PI)

                                        #748977
                                        Andy Stopford
                                        Participant
                                          @andystopford50521

                                          One thing to watch out for with ESPs is that there are many cheap knock-offs, and sometimes the WiFi on them doesn’t work properly – I once bought what seemed like a good deal for five from ebay, and WiFi only worked on one. Also, they sometimes have variable numbers and positions of pins.

                                          #748993
                                          SillyOldDuffer
                                          Moderator
                                            @sillyoldduffer
                                            On John Haine Said:

                                            Just to add, I found this yesterday:

                                            https://randomnerdtutorials.com/programming-raspberry-pi-pico-w-arduino-ide/#Raspberry-Pi-Pico-Boards-Manager

                                            I have just followed the procedure there to install the Pico 2040 to the Arduino IDE and it was trivial.  Not tried programming yet but looks promising.  Being pretty familiar now with the Arduino this looks a good way forward.

                                            When the Pico2040 first hit the streets, the Arduino IDE had almost no libraries for the Pico.   If a programmer wanted to use a DS18B20 temperature sensor, he had to write code implementing the OneWire interface and the Dallas Temperature protocol.   The compiler fully supports the programming needed, but implementing low-level system functions from the datasheets is hard work.  Easier to find an existing library implementation for a similar chip and modify it.  I was going to recommend the mbed and ESP libraries as a start.  Still hard work.

                                            Good news is that a large number of Pico libraries have become available for the Arduino IDE since the last time I looked.   For Robin’s application, I recommend the DS18B20 sensor because it covers the necessary fridge temperature range with good accuracy and an encapsulated version is available.

                                            ds18b20

                                            Haven’t been able to get Pico to read a DS18B20 yet!

                                            Dave

                                             

                                            #749313
                                            SillyOldDuffer
                                            Moderator
                                              @sillyoldduffer
                                              On SillyOldDuffer Said:
                                              On John Haine Said:

                                              Just to add, I found this yesterday:

                                              https://randomnerdtutorials.com/programming-raspberry-pi-pico-w-arduino-ide/#Raspberry-Pi-Pico-Boards-Manager

                                              I have just followed the procedure there to install the Pico 2040 to the Arduino IDE and it was trivial.  Not tried programming yet but looks promising.  Being pretty familiar now with the Arduino this looks a good way forward.


                                               

                                              Haven’t been able to get Pico to read a DS18B20 yet!

                                              Dave

                                               

                                              Success.

                                              In the Arduino IDE I set the connection to ‘Raspberry Pi Pico’, and then installed the library ‘NonBlockingDallas’.   (Others available: I tried this one because it’s non-blocking, that is the program asks the sensor to take a reading and doesn’t wait for the reply.  When the reply arrives it interrupts the program, which reads it, and then carries on with whatever it was doing when the reply arrived.

                                              I loaded the program TemperatureReading.ino from File->Examples->NonBlockingDallas.   (Most Arduino libraries come with example programs showing usage.)  It prints output to the serial port.

                                              Didn’t work:

                                              • I forgot the DS18B20 requires a 4K7 pull-up resistor
                                              • I misread the resistor colour code and plugged in a 2K2.  Note to self, admit I’m of an age that needs a magnifying glass!
                                              • Fell into booby trap.   The program says the sensor connects to Pin2.   Not Pin 2 on the Pico board,  they mean processor pin GP02.  GP02 is Pin 4 on the Pico board.

                                              I’d also forgotten the Pico has to be forced into program download mode by unplugging the USB cable, holding down the button labelled BOOTSEL on the Pico, reinserting the USB, and releasing the button.

                                              DSC06859

                                              In the photo, the DS18B20 is bottom left, connected to GP02 with the long green jumper wire.

                                              The red unit is a 3.3 to 5V level converter, needed if I add the LCD display to the set-up.  The LCD is a 5V only peripheral.  The DS18B20  runs at either 3.3 or 5V.  The red and blue wires trailing across the LCD go to my oscilloscope so I can watch what GP02 is doing.   Nothing seen unless a 4K7 pull-up is connected!

                                              Dave

                                              #749960
                                              Robin Graham
                                              Participant
                                                @robingraham42208

                                                Thanks for further input – all very useful.

                                                At some point I think I lit on the possibility of using the Arduino IDE to program the pico, but I’ve gone off on so many tangents with all this that it got lost.

                                                I revisited the Arduino IDE and did indeed see ‘Arduino Mbed OS RP2040 Boards -> Raspberry Pi Pico’ in the ‘Board’ menu.  I tried with ‘Blink’ which seemed to compile / build OK, but gave an unhelpful ‘Error Uploading’ message.  I then installed the RP2040 package from Earle Philhower and all went well.  So, focusing on the Pico route possibilities seem to be:

                                                • Arduino IDE + the EarlePhilhower RP2040 board package.  If the various Arduino libraries for specific peripherals work this looks to be the easiest way forward.  Dave’s result with the DS18B20 is encouraging.
                                                • RP’s own Pico SDK.  This allows building executables from source using the command line.  The SDK provides scripts for processing source using both CMake and Bazel which are industrial strength tools designed to allow compiling/linking code written in a variety of languages for a variety of target platforms. So necessarily complex.   Not trivial to get to grips with (for me at least), but allows direct access to the comprehensive SDK.
                                                • Various IDE tools (eg VScode, as recommended by RRi).  These are GUI ‘wrappers’ for CMake &c so far as I can make out. I had zero success with them despite spending quite a lot time trying. In the link I gave earlier Lief Koepsel says: “I won’t use Visual Studio Code as the Pi Foundation and many others advocate. I have found Code introduces as many problems as it attempts to solve and I don’t care for its interface. I’ve found its better to understand the under-lying tool gdb than abstract it away with the clutter of Visual Studio Code. If you develop code for living, by all means, use the tool of professionals, an IDE. If you are experminting/learning/hacking, focus on the project not learning how to use an IDE.

                                                Joseph: Thanks for the pointer to Node-Red.  If/when this comes to home/workshop automation that looks like a great tool and I’ll follow it up.  Your sample image is impressive! It will cause domestic friction if I can control the central heating from my desktop though…

                                                Dave: I actually have a DS18B20 which I got working fine with a Nano and the DallasTemperature library. It’s impressive for such a cheap device. I got 0.3-0.4 C in an ice/water bath which gave 0-0.2 C using a PT100 resistance probe.  Good to hear you got it going with the Pico. I was planning to use PT100s which work well with the Adafruit MAX31865 board, but not with the cheap (<£5) clones which were up to 2C out when they worked at all.  These all use SPI – I’d be interested to hear of any results using SPI on the Pico.

                                                I’ve made some progress with CMake, and I’m not ready to give up with this approach yet, though if the Arduino IDE can do the job….

                                                Robin.

                                                #749967
                                                MikeK
                                                Participant
                                                  @mikek40713
                                                  On Robin Graham Said:

                                                  I actually have a DS18B20 which I got working fine with a Nano and the DallasTemperature library. It’s impressive for such a cheap device.

                                                  For what it’s worth…if it was cheap, it is a fake from China.  The real deal is around $6 and only comes from authorized vendors.  There’s an Arduino library that can check the authenticity of the device with reasonable confidence.  If one cares, though.  Fake devices *can* cause problems, but I’ve used a few without drama.

                                                  Mike

                                                   

                                                  #750049
                                                  SillyOldDuffer
                                                  Moderator
                                                    @sillyoldduffer
                                                    On Robin Graham Said:

                                                    At some point I think I lit on the possibility of using the Arduino IDE to program the pico, but I’ve gone off on so many tangents with all this that it got lost.

                                                    The advantage of the Arduino IDE is that it’s specifically designed to simplify programming microcontrollers.  A lot of difficult detail is hidden behind the scenes, allowing programmers to concentrate on writing code, not spending days setting the environment up.

                                                    I revisited the Arduino IDE and did indeed see ‘Arduino Mbed OS RP2040 Boards -> Raspberry Pi Pico’ in the ‘Board’ menu.  I tried with ‘Blink’ which seemed to compile / build OK, but gave an unhelpful ‘Error Uploading’ message.

                                                    The upload failed because the Pico wasn’t in BOOTSEL mode.   Most boards programmed by the Arduino-IDE switch automatically into upload mode, but despite claims it should after first connect, I find my RP2040 doesn’t.   It’s important to get this right, Adafruit’s instructions has a little video!

                                                     

                                                    I then installed the RP2040 package from Earle Philhower and all went well.  So, focusing on the Pico route possibilities seem to be:

                                                    • Arduino IDE + the EarlePhilhower RP2040 board package.  If the various Arduino libraries for specific peripherals work this looks to be the easiest way forward.  Dave’s result with the DS18B20 is encouraging.

                                                    I’d rather stick with the Arduino teams standard package.   Could be wrong, but I think it’s better supported in terms of advice and libraries.   Low risk – if EarlePhilhower lets you down, not difficult to go back.

                                                    • RP’s own Pico SDK.  This allows building executables from source using the command line.  The SDK provides scripts for processing source using both CMake and Bazel which are industrial strength tools designed to allow compiling/linking code written in a variety of languages for a variety of target platforms. So necessarily complex.   Not trivial to get to grips with (for me at least), but allows direct access to the comprehensive SDK.

                                                    Extremely complex.  The Arduino-IDE is designed to be beginner friendly, and it’s a good learner platform.  The Pico-SDK does much more than the Arduino-IDE but the beast isn’t intended for beginners!

                                                    • Various IDE tools (eg VScode, as recommended by RRi).  These are GUI ‘wrappers’ for CMake &c so far as I can make out. I had zero success with them despite spending quite a lot time trying. In the link I gave earlier Lief Koepsel says: … If you develop code for living, by all means, use the tool of professionals, an IDE. If you are experminting/learning/hacking, focus on the project not learning how to use an IDE.

                                                    That’s good advice.  Professional programmers don’t like the Arduino-IDE much because it doesn’t let them change what goes on behind the scenes.   Though it might matter to a pro which ‘make’ tool is used, the average Joe is unlikely to care.

                                                    Dave: I actually have a DS18B20 which I got working fine with a Nano and the DallasTemperature library. It’s impressive for such a cheap device. I got 0.3-0.4 C in an ice/water bath which gave 0-0.2 C using a PT100 resistance probe.  Good to hear you got it going with the Pico. I was planning to use PT100s which work well with the Adafruit MAX31865 board, but not with the cheap (<£5) clones which were up to 2C out when they worked at all.  These all use SPI – I’d be interested to hear of any results using SPI on the Pico.

                                                    There is a Pico library in the Arduino Library Manager that supports the PT100, called RAK12022-MAX31865.   Details on github here.   SPI should work on the pico – there’s a standard library – #include <SPI.h>

                                                    Robin.

                                                    Further to my DS18B20 experiment, I connected three sensors in parallel to see if the library detects that automatically.  It does.  DS18B20 sensors have a unique address, that the library presumably detects by scanning the bus when the program starts.   The example program prints results like this:

                                                    dallatemps

                                                    The program identifies particular sensors by ‘deviceIndex’.

                                                    Oh, and Mark’s warning about fakes might explain why my device 2 consistently reads a degree low!  Hmmm…

                                                    Dave

                                                     

                                                    #750581
                                                    Robin Graham
                                                    Participant
                                                      @robingraham42208

                                                      Well, I’m increasingly coming round to the Arduino IDE way of doing things. Tonight I got the PT100 sensors working with the Pico  in both ‘bit banging’ and hardware modes using Adafuit’s Max31865 SPI board, the Adafruit MAX_31865 Arduino library and the EarlPhilhower RP2040 board package .  I was surprised – it just worked first time.  A lot of effort must have gone into porting this!

                                                      As an aside the SPI hardware interface clock runs at 1.00MHz and the ‘bit bang’ version at a creditable (I thought) 420kHz.

                                                      Dave- it wasn’t the BOOTSEL thing that caused the failure to upload with the Arduino standard package.  I too had been tripped up with that earlier and used the correct method.  I don’t know what went wrong – maybe I installed the package incorrectly.  If you haven’t come across it, the ‘hack’ is to short (physical) pin 30 (marked RUN on the board) to ground  , press BOOTSEL, remove short then release BOOTSEL.  The Pico will then revert to mass storage mode ready for downloading a UF2 file. I did that a few times then tried without (while the pico was running)  and sure enough  when I hit ‘Upload’ in the IDE it reported that it was searching for an RP then switched the pico to mass storage without intervention as advertised. God knows how it works, but it does!

                                                      Shorting RUN to ground is actually a ‘reset’ in the sense that it restarts execution from main() in the SDK world or setup() in Arduino code, rather than suspending execution and carrying on from where it left off. Note to self!

                                                      Robin

                                                    Viewing 25 posts - 1 through 25 (of 27 total)
                                                    • Please log in to reply to this topic. Registering is free and easy using the links on the menu at the top of this page.

                                                    Advert

                                                    Latest Replies

                                                    Home Forums The Tea Room Topics

                                                    Viewing 25 topics - 1 through 25 (of 25 total)
                                                    Viewing 25 topics - 1 through 25 (of 25 total)

                                                    View full reply list.

                                                    Advert

                                                    Newsletter Sign-up