#112

Sdílet
Vložit
  • čas přidán 31. 05. 2018
  • The Raspberry Pi (I'm using a Model 3B+) has no analog input pins at all. So how do you measure analog voltages then?
    Simply connect a Microchip Analog-to-Digital-Converter (ADC) chip that uses SPI and you're in business. Just to make it really easy we can use a kit of parts from RasPiO, a UK-based company.
    I have no connection with this company at all, and I didn't get the product for free or at a reduced rate.
    I noticed whilst editing this video that the audio could vary as I turned from desk to soldering station; I'm already thinking of what I can do to improve this (without buying another expensive microphone). I might be able to use the built-in microphone from my video camera to augment the audio. We shall see how it works in future videos!
    The sketch (OK, Python program) can be found in my Github
    github.com/RalphBacon/Raspber...
    Source of the Analog Zero kit
    rasp.io/analogzero/
    User guide for the Analog Zero kit (very useful)
    rasp.io/wp-content/uploads/201...
    Datasheet for the 10-bit Microchip 3008
    ww1.microchip.com/downloads/en...
    Datasheet for the 12-bit Microchip 3208
    ww1.microchip.com/downloads/en...
    VNC viewer for connecting your Windows PC to the Raspberry Pi
    www.realvnc.com/en/connect/do...
    ---
    If you like this video please give it a thumbs up, share it and if you're not already subscribed please consider doing so :)
    My channel and blog are here:
    ------------------------------------------------------------------
    / ralphbacon
    ralphbacon.blog
    ------------------------------------------------------------------
  • Věda a technologie

Komentáře • 99

  • @russellmoore1312
    @russellmoore1312 Před 6 lety +1

    Thanks Ralph, very interesting and informative

    • @RalphBacon
      @RalphBacon  Před 6 lety

      Thanks for that, Russell Moore, nice to hear from you. Hang on, is this the Russ that sold me this? I hope it helps your sales too!

  • @dreamaxtutoring8395
    @dreamaxtutoring8395 Před 5 lety

    thanks man, really benefited from this

    • @RalphBacon
      @RalphBacon  Před 5 lety

      Really glad that's the case, thanks for posting.

  • @UDoIt2
    @UDoIt2 Před 5 lety

    Excellent video Ralph. I found your channel looking for opto-isolators and then poked around and found this. I plan on using the MCP3008 also. And why didn't they point ADC on the PI????

    • @RalphBacon
      @RalphBacon  Před 5 lety

      And I'm glad you found me!
      I dabble with the Pi, but it's too big a product (not to mention too expensive) to use in a willy-nilly fashion when compared to a £2 Arduino Uno or Nano! It can run my entire workshop automation system using Node-Red and MQTT, for goodness sake!
      Yes, I think they should have included ADC on the Pi too, for an extra $1 they could have managed it. Oh well...

  • @MartinBgelund
    @MartinBgelund Před 6 lety

    Thanks for the video. I've done a project with a Raspberry Pi and the MCP3008. It does its job and is very easy to work with. I'm considering the ADS1015 and the ADS1115 ADC's now, since I want to use I2C instead of SPI.
    Any thoughts or experience with those two?

    • @RalphBacon
      @RalphBacon  Před 6 lety +1

      Yes, Martin, I did a video on the ADS1115 just a few weeks ago, it's video #104. It worked quite well but there was some noise as they were very sensitive. I used an Arduino but they will work equally well on a RasPi. I hope this helps!

  • @Mike_Downey
    @Mike_Downey Před 6 lety

    That ic pin straightener is a good idea. I haven't seen one of those before.

    • @RalphBacon
      @RalphBacon  Před 6 lety

      That means you haven't watched some of my previous videos, Mike, describing essential tools 😱 but never mind, now you know and I must say I have found it indispensable over the last (cough, mumble, 30) years or so. Probably time I bought a shiny new one, actually. Thanks for posting.

  • @DMIINC2013
    @DMIINC2013 Před 4 lety

    Hello, very nice channel. Was wondering would this be suitable to read values from 100mV shunt or would you recommend something else?

    • @RalphBacon
      @RalphBacon  Před 4 lety +1

      Reading very low voltages across a shunt can bring problems in the shape of noise (it's analog). You could use a INA219 to do all this via I2C, very good chip, see it all in video #186.

    • @DMIINC2013
      @DMIINC2013 Před 4 lety +1

      @@RalphBacon Very nice. Thank you.

  • @willofirony
    @willofirony Před 6 lety

    Excellent video, Ralph. Not a Pi person myself bu,t lets say, I was very tempted. Your example of the use of Python was very valuable for the Neophyte. Python is very easy to work with and one can get VERY sophisticated applications up and running just as fast as one likes. Being an interpreted language (i.e. no compilation needed), one can get stuff running very quickly; debugging line by line. I actually use it to develop desktop applications, then once the principles are proven, I write it all in C++. Using it, in a way, like one would use a development board to develop a circuit, then transposing the breadboard layout into a proper PCB (or vero) layout. Loved the fancy video segues .

    • @RalphBacon
      @RalphBacon  Před 6 lety

      That's an interesting way of developing a desktop app, that you describe there, Michael. Quick to develop (and debug, but you don't have any bugs, right?) and then rewrite in lower level language. Nice. Glad you liked the video, thanks for posting.

    • @willofirony
      @willofirony Před 6 lety

      I did write a bug back in the eighties. Never again!

  • @maurice22
    @maurice22 Před 2 lety

    Brilliant video. Coming from no Arduino experience! I want to use the Resistance reading from a Wind direction vane so this kit will do nicely. But, how do I convert the readings to wind direction?

    • @RalphBacon
      @RalphBacon  Před 2 lety

      Find the limits of the resistance around the 360 degrees (eg zero to 10KΩ or 100KΩ) axis. Then _map_ the resistance (that's an Arduino function) to 360 degrees. That might mean you have set it up that North maps to 122º instead of 5º so you will need to subtract/add the required offset to get it right.

  • @avejst
    @avejst Před 5 lety

    Nice project
    Thanks for sharing :-)

    • @RalphBacon
      @RalphBacon  Před 5 lety

      You are most welcome Asger Vestbjerg, I'm glad you like the video. Nice to hear from you.

  • @joshuabrand11
    @joshuabrand11 Před 3 lety

    Great video - would I be able to plug a Resistance Level Sender into this? The type with the float which changes the resistance as the float moves up and down it?

    • @RalphBacon
      @RalphBacon  Před 3 lety +1

      Yes, you can. The analog inputs behave exactly as you would expect.

    • @joshuabrand11
      @joshuabrand11 Před 3 lety

      Awesome! I believe the sender is currently powered by a 12v power supply, could I just put a 12v - 3.3v step down in-line?

  • @vasireddyrenukaa1638
    @vasireddyrenukaa1638 Před 4 lety

    Hi actually I wanted to read 90 analog pin address using thermocouple sensor what should I do and how can I do that ?
    Either Ads1115 is better or mcp3008 is better?

    • @RalphBacon
      @RalphBacon  Před 4 lety

      ADS1115 is only 4-channel AFAIK, whereas the MCP3008 is 8 channel. But to read 90 inputs is going to be a challenge. I'd do a proof of concept with just a couple of MCP3008 and make sure that all hangs together on the breadboard. Each MCP3008 requires a Chip Select pin (it's SPI driven) so you would need 90 / 8 = 12 pins to be able to select each MCP3008 in turn - best to use a MEGA2560 rather than run out of pins on an Arduino.

  • @pranavthakkar8089
    @pranavthakkar8089 Před 4 lety

    thank you ralph, I'm also using MCP3008 and I have 8 analogue sensors(measuring Voltage, current).
    Can I get the value of this 8 at one time? if yes, How?

    • @RalphBacon
      @RalphBacon  Před 4 lety

      You will doubtless have to poll each of them in a loop, changing the I2C address (if they are I2C devices) and read the resultant value. It will only take a few milliseconds to do this, so it will appear as if you had read them simultaneously.

  • @testchannel1834
    @testchannel1834 Před 5 lety

    hi can you do a part 2 to this video and use a 0.96" I2C IIC Serial 128X64 128*64 Blue OLED LCD LED Display Module to display readings please . can you add also a bme280

    • @RalphBacon
      @RalphBacon  Před 5 lety

      I shall add your suggestion to my list and see what happens!

  • @zacklinder344
    @zacklinder344 Před rokem

    I am very late to this comment section, but I was wondering if there was any way to get more than 8 analog pins out of a single board, either using a different board or expanding on this one. I need 12 in total, all controlled by RPI 4. Any suggestions would be appreciated...

    • @RalphBacon
      @RalphBacon  Před rokem

      Have you researched daisy chaining these devices?

  • @reelrebellion7486
    @reelrebellion7486 Před 6 lety

    I'm a fan of inserting one row of ic pins in the socket, pressing against them with just slightly less pressure than it takes to collapde the pins. Then jamming the other row in place at just below light speed hoping they are lined up. I have greater than 12% success with that method! Although I imagine the pin straightener could help with recovering the failures.

    • @RalphBacon
      @RalphBacon  Před 6 lety

      I used to do it your way, Kent, before I got this pin straightener, then never looked back. They are quite cheap so I can only suggest you try one, you might prefer it and get your success rate to 99.99%! Thanks for posting.

  • @001CLUB
    @001CLUB Před 4 lety

    If I need two more analog inputs, do I need two more MCP3008??

    • @RalphBacon
      @RalphBacon  Před 4 lety

      4 (MCP3004) or 8 (MCP3008) input channels (per chip).

  • @legosteveb
    @legosteveb Před 4 lety

    Love your attention to detail! I have a question, being a noob to raspberry pi, transitioning from Teensy Arduino-land. Most of my Arduino code is executed via interrupt timers (never the main loop), sort of a poor man’s real time operating system. I’m hoping to write some pretty intensive code on the raspberry pi; a digital synthesizer and also some 3D rendering. I would like to know how typical raspberry pi apps handle the GPIO ports (shift registers etc) for the buttons and encoders and pots, without burdening the other SW tasks? Can a separate core for handling GPIO be setup?
    Thanks in advance,
    Steve

    • @RalphBacon
      @RalphBacon  Před 4 lety +1

      I'm afraid I am inexperienced with the Pi's way of dealing with separate cores. However, you are always at the mercy of the operating system and a hardware interrupt on an Arduino will be serviced immediately, whereas on the Pi it is whenever the OS decides that "now" is the right time - which could be several milliseconds (or more) later, depending on what the Pi is doing at the time. Same goes for Windows, of course, where you might click something and nothing happens until Windows decides to service that request (probably just at the same time you click it again in frustration). The ESP32 is a much more powerful, Arduino-compatible, dual core device but also suffers from OS "lag" to a degree.

    • @legosteveb
      @legosteveb Před 4 lety +1

      Thanks for your reply Ralph! I know that Windows is a NOT a real time OS, ug. I take Real Time (RT) to mean deterministic interrupt timers, NOT a fast OS (as I have heard many say or assume). In my research of Raspberrian there is an option to have a RT kernel for the R-Pi. I guess I assumed that it really meant RT. Couple that with a 4 core proc and I further assumed that your could assign a core to handle the deterministic interrupt timer callbacks and GPIO HW interrupts. Hopefully this question will generate some more discussion or a good recommendation for a web source for R-Pi RT info. : - )
      Thanks
      Steve

  • @ReflectingMe2024
    @ReflectingMe2024 Před 6 lety

    Another great video, Ralph. Found this one particularly useful, thank you. It is a niggle isn't it, that the otherwise wonderful Pi, has no analogue inputs.

    • @RalphBacon
      @RalphBacon  Před 6 lety

      Glad you liked it, John, and yes, I do find it surprising they have no in-built analog ports but they are very price conscious. But the next model may have some, who knows? Glad you liked the video, thanks for posting.

  • @tableaux302
    @tableaux302 Před 4 lety

    Hi ralph, does this let me analyze multiple sensors at once? I mean can I observe each individual sensor's output? So one is say a pressure sensor and another a temperature sensor?

    • @RalphBacon
      @RalphBacon  Před 4 lety

      Yes you can! Each sensor can connect to a different analog input pin and you can read each pin in turn. I would prefer digital sensors that I can interrogate using I2C but that's just me!

    • @tableaux302
      @tableaux302 Před 4 lety +1

      @@RalphBacon Thanks so much for such a quick reply!

  • @HarboroughHoney
    @HarboroughHoney Před 3 lety

    Hi Ralph, I have been watching your videos with great interest and find them facinating. I am going to be building a weather station and likely to need about 10 or so analog inputs aswell as a few digital.
    Are you able to confirm if you can connect two of the Analog Zero's to the Raspberry Pi 4? I see Rasp.io do a FullpHAT so that you can connect two smaller boards like the Analog Zero, but wasn't sure if this was possible or how the RPi would know which chip select is being used? CE0 or CE1? The other question is, if i want to put another board on top of the Analog Zero, presumably if i put long pins through, i can then extend off that instead of using the side chained ports. It would be easier to have a double row of 20 for me. Thank you.

    • @HarboroughHoney
      @HarboroughHoney Před 3 lety

      It's at about 10:40 in your video you mention the SPI port 0. I can see how to adjust the script, thats clear enough, but wasn't sure how you determine which ADC / Analog Zero ends up on which CE0 or CE1 ? Any points would be appreciated thanks. It says on Page 4 of the instructions for the Analog Zero "The Pi's SPI can handle two devices natively. If you wish to add another
      SPI device, ensure its chip-select pin is connected to CE1 or it will interfere with the MCP3008 chip, which uses CE0" ?

    • @RalphBacon
      @RalphBacon  Před 3 lety

      I'm sorry to say I don't know the answer. Normally I'd at least try and find out but my workshop is all packed up pending a house move with week. I'm no expert on the Pi though, others will undoubtedly be of better help than me (just on this one occasion though!)

    • @brandonvanderryst176
      @brandonvanderryst176 Před 3 lety

      @@HarboroughHoney You might want to look into NODE-RED its a program on the raspberry pi. Should make your weather station much easier to build

  • @mustafaglnr8780
    @mustafaglnr8780 Před 5 lety

    Isn't it easier wit ARDUINO?
    if we do that with ARduino , what should we do that?

    • @RalphBacon
      @RalphBacon  Před 5 lety

      An Arduino has five (sometimes 7) analogue ports already built in - the Raspberry Pi has none, hence this video!

  • @Ed19601
    @Ed19601 Před 6 lety

    Very nice.
    remember the PCF8591 module? That works great on my raspi, but ofcourse it isn't a neat HAT, yours looks much nicer and of course more sensitive
    With the 12 bits chip the reading of '2' is equal to 1.6mV. Wiring could easily have picked that up along the way

    • @RalphBacon
      @RalphBacon  Před 6 lety +1

      Ah, yes, the PCF8591 I2C expander module, Ed, which if I recall also works on both 3v3 and 5v. I agree that there could be noise on the wiring, it's not a deal breaker. Thanks for posting.

    • @Ed19601
      @Ed19601 Před 6 lety +1

      Ralph S Bacon Got to work with what you have and the 8 bits was enough for my needs. Nevertheless it was good finding the gpiozero library through yr video

  • @artbecker5618
    @artbecker5618 Před 6 lety

    Thank you for putting the links in your github project page. The redirected links that CZcams forces on us, in Show More, are a major pain, and frequently don't even work, due to being so convoluted. They certainly can't be copied by us into a text file, to accompany a useful video, like the ones you produce. Another way to post actual direct links is in a sticky comment.

    • @RalphBacon
      @RalphBacon  Před 6 lety

      It might even have been you, Art, that urged me to do this (if not you, then another Arduinite fan). Glad it helps and thanks for posting.

  • @rayleblanc7209
    @rayleblanc7209 Před 3 lety

    Hi Ralph. I heard you mention "From Arduino world". Can you use the analog inputs from an Arduino with a raspberry instead?

    • @RalphBacon
      @RalphBacon  Před 3 lety

      Well, you _could_ I suppose, and send the value via I2C (for example) to the Pi, but is that easier than this solution?

    • @rayleblanc7209
      @rayleblanc7209 Před 3 lety

      @@RalphBacon Being a newby to the Raspberry pi and python scripting is a very challenging task. However I managed to figure out a python script that reads the analog input connected to a potentiometer on my arduino mega 2560 and convert it to a scale of 0-180 to control a servo connected to a digital pin. I am using the Firmata protocol for the mega uploaded to my Arduino with a USB connection to my Raspberry Pi 4. The raspberry is connected to my laptop via ethernet cable. My next challenge is to figure out how to read PPM /PWM signals from a Flysky RC controller connected to my Arduino digital pins and control attached hardware like servos, motors and switches with the raspberry.

  • @frodev728
    @frodev728 Před 5 lety +1

    what if we need to measure more than 3v? up to 16v for example?

    • @RalphBacon
      @RalphBacon  Před 5 lety +3

      You need a resistor divider, or resistor ladder, so you can switch in various resistors to measure a higher voltage. Google will show you what you need.

    • @frodev728
      @frodev728 Před 5 lety

      Ralph S Bacon thank you 🙏

  • @bekkarimohammed3312
    @bekkarimohammed3312 Před 3 lety

    Hi did you try Analog input Raspberry pi with OpenPLC IDE ?

  • @dartrunner4599
    @dartrunner4599 Před 2 lety

    How would you use a sensor that required 5v minimum?

    • @RalphBacon
      @RalphBacon  Před 2 lety

      If a sensor is running on 5v, you can use a level shifter, a very simple device, usually bidirectional and multiple channels (4 or 8).
      This will 'shift' the voltage from 5v to 3v3 (and vice versa). They are cheap and work well.
      I'm using one in a current project so allow an ESP32 (3v3) to drive a NeoPixel (5v).

  • @neophyte88
    @neophyte88 Před 4 lety

    can i use this thing on a jetson nano?...

    • @RalphBacon
      @RalphBacon  Před 4 lety

      I'm sorry Vedprakash, I don't even know what a jetson nano is. Google may be your best friend or ask the question at forum.arduino.cc

  • @sigmata0
    @sigmata0 Před 3 lety

    I know this is an old video, and I presume others have said this already.
    Rather than VNC I'd run two ssh sessions to the Pi. One to allow you to edit your python code and the other to run it and see the output.
    That should be a great deal faster, as processing text is easier by far than processing a video stream. You shouldn't get those "freezes".
    For Windows I'd run something like PuTTY. For Linux and Mac there are native ssh clients.
    The downside is that you'd be using a native Linux editor and it won't give you hints about the syntax of the python code, although there are ways around that.

    • @RalphBacon
      @RalphBacon  Před 3 lety +1

      Yes, all good advice and I have experimented quite a bit but as I don't code much for the Pi (Python? Pah!) I've not had an issue to date. When I start coding C/C+ for the Pi that might change, of course.

    • @sigmata0
      @sigmata0 Před 3 lety +1

      @@RalphBacon
      Cool :-)

  • @Roy_Tellason
    @Roy_Tellason Před 4 lety +1

    Why multiply the reading by 1023 (2**10 - 1) in the one case, but 4096 (2**12) in the other? That's inconsistent...

    • @RalphBacon
      @RalphBacon  Před 4 lety +1

      Is one of them 10-bit and the other 12-bit? On the other hand, consistency has never been my strong point, Roy!

    • @Salty_Knuckles
      @Salty_Knuckles Před rokem

      Shouldn’t it be 4095? Also he didn’t change the import library to the MCP3208 chip from the MCP3008.

  • @simonbeswick1436
    @simonbeswick1436 Před 4 lety

    Hi , I am using pi 4, is there a newer version for this analogue board, also the python is thorny python ide, is this the same

    • @RalphBacon
      @RalphBacon  Před 4 lety

      I believe this should work just the same, as long as they still expost the RUN pad.

  • @tabmaryland2333
    @tabmaryland2333 Před 6 lety

    Good video, but it would be nice to actually verify that you are getting 12 bits resolution by measuring Vin vs count out. Thanks!

    • @RalphBacon
      @RalphBacon  Před 6 lety

      Proof, you mean, Tab Maryland? 😳 From those fly-by-night MicroChip engineers? Gasp. Well, if I use this module again in a video I will try and remember to include this measurement!

  • @KennethLavrsen
    @KennethLavrsen Před 6 lety

    The reason IC pins are not straight is for the pick and place machines. Pins will never be equally straight. By being all bent out, the pick and place tool holds the IC so pins are pushed in and this way they are all straight when inserted in the PCB

    • @RalphBacon
      @RalphBacon  Před 6 lety

      Well, there had to be a reason and this sounds as plausible as any, Kenneth, so it probably true. Those pick and place machines have a lot to answer for! Thanks for letting us know this.

  • @fieryfirevivin
    @fieryfirevivin Před 5 lety

    Anyone have the library for the ADC ADS8345

    • @RalphBacon
      @RalphBacon  Před 5 lety

      Are you sure you have that part number correct, Vivin?

    • @fieryfirevivin
      @fieryfirevivin Před 5 lety

      @@RalphBacon I'm sorry Ralph. It was a typo on my part. The part type was ADS 8345

    • @RalphBacon
      @RalphBacon  Před 5 lety

      I can't find a library for the Arduino (or any other µController) for this device, sorry.

  • @bubbasnmp
    @bubbasnmp Před 6 lety +1

    After swapping to the 12-bit MCP3208 chip you need to update the Python code to use the proper device:
    gpiozero.readthedocs.io/en/stable/api_spi.html#analog-to-digital-converters-adc
    class gpiozero.MCP3008(channel=0, differential=False, max_voltage=3.3, **spi_args)[source]
    The MCP3008 is a 10-bit analog to digital converter with 8 channels (0-7).
    class gpiozero.MCP3208(channel=0, differential=False, max_voltage=3.3, **spi_args)[source]
    The MCP3208 is a 12-bit analog to digital converter with 8 channels (0-7).
    At 20:35 in the video that's why your max values bounce between 4092 and 4096, not single bits of noise.

    • @RalphBacon
      @RalphBacon  Před 6 lety +1

      I did try the other library before I did the video, but found no difference in behaviour. At that point, I thought that perhaps the libraries were identical but named differently just to match the chip. Perhaps I didn't do it right. I'll have another go and if I have more success I'll update in a future video. Thanks for the nudge, bubbasnmp.

    • @bubbasnmp
      @bubbasnmp Před 6 lety +1

      Good luck! Shipping to USA is reasonable so might have to add this to my project list. Thanks for the video.

  • @SinanAkkoyun
    @SinanAkkoyun Před 3 lety

    Normal people: Nord-VPN
    Bacon: 0-VPN

  • @vonries
    @vonries Před 6 lety

    More for your ATtiny. Just need more memory.

    • @RalphBacon
      @RalphBacon  Před 6 lety

      My thoughts are, vonries, that the ATTiny and the Pi have nothing in common, apart from the fact they are both digital processors of sorts. If the Tiny can do the job we need look no further. And, sure, the Tiny can read three Analog inputs without recourse to another board, but it wasn't the point I was making in this video (which I'm sure you realise).
      As you know I've done a few videos on the Tiny85, and it's amazing what it can do given its size and price. But the RasPi is a different beast altogether. Now _there's_ an idea for another video!

  • @avejst
    @avejst Před 6 lety +1

    Thanks for sharing
    Nice project :-)

    • @RalphBacon
      @RalphBacon  Před 6 lety

      Thanks for your post, Asger Vestbjerg, good to hear from you.