igrvlhlb
Posts: 6
Joined: Sat Mar 18, 2023 3:57 am
Location: Rio de Janeiro, Brasil

I need some help on how to make my project

Sat Mar 18, 2023 4:32 am

Hello!
It's my first experience with Raspberry Pi and I am in charge of a project where the following has to be done: a Raspberry will be collecting data from a GPS and a temperature sensor and show the temperature in a display. Also, it will have a GSM/SIM/Cellular card adapter for it to send data through the internet.
So far so good, but here is an important detail: the temperature sensor won't be close to the Raspberry (something within 10 meters away), so it's almost mandatory that their connection will be wireless. Also, it will be in a vehicle where there is no Wi-Fi, so there is no way to connect via a router. I have some questions to make:

1. Is it possible to have a wireless connection between the Raspberry and the temperature sensor directly? I mean, without a router, just one sending data to the other via Wi-Fi direct or Bluetooth... (it's ok if I'll need an Arduino, but I'd still appreciate if you could tell me how to do it or suggest some tutorial, because I have no idea about it...)
2. How do I pack the Raspberry with the GPS sensor, and attach the display to the case? And how to choose a case for my setup?
3. Is there a specific Raspberry model that would be the best for this project?

I already have a good experience with programming and have read some about how to communicate with Raspberry though Python, so my main concern in code will be how to communicate wirelessly. But for that I still need to find out what hardware will be needed, which I have no idea about :(

Thank you in advance!

stevenbowyer
Posts: 147
Joined: Wed Nov 20, 2019 6:59 pm

Re: I need some help on how to make my project

Sat Mar 18, 2023 5:36 pm

You could have the pi run in AP (Access Point) mode and have the sensor connected to a WiFi capable microcontroller (Pico W, ESP32, ESP8266 etc).

The microcontroller is programmed to connect to pi AP with static IP).

The microcontroller runs a webserver that outputs sensor data periodically to a known format (i.e. JSON). The pi periodically requests this data from the microcontroller.

Others may have other ideas (I have seen there is a project that has got the ESP-NOW protocol working in Linux, so that could be another way if you used an ESP microcontroller, but I not used or looked into it).

igrvlhlb
Posts: 6
Joined: Sat Mar 18, 2023 3:57 am
Location: Rio de Janeiro, Brasil

Re: I need some help on how to make my project

Sat Mar 18, 2023 10:44 pm

Thank you very much! I have a question about that solution: if I run the Raspberry in AP mode, will I still be able to connect to internet via the SIM card adapter? If so, I'm sure I'll be following your suggestion. It looks perfect for my situation! I'm probably going with Pico W

Also, do you have any tips on how find the right cases to hold those two groups of devices? I'd like to put them somewhere they won't get loose, as they will be inside a shaking vehicle.

peterlite
Posts: 820
Joined: Sun Apr 17, 2016 4:00 am

Re: I need some help on how to make my project

Sun Mar 19, 2023 1:50 am

Is the sim card adaptor listed as a network device? You can use hostapd and stuff to make the WiFi into an AP then treat the SIM device as the network source for DNS etc.

Depending on your network connection, you might have to use something like dnsmasq to provide DNS to the device connected to the AP.

I like Zero W for the connection task. You are then working with the same OS and software. You can connect the sensor to your Pi 4 or whatever for development in 32 bit OS then move the microSD card to the Zero W. Boot new card in the Pi 4 and start the network connection work.

I work much the same because I have old Zero and Zero W and 3Bs in a box in the garage. Pi 4 makes every dev task faster. Then move the card to one of the cheaper machines for regular use.

ame
Posts: 6714
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: I need some help on how to make my project

Sun Mar 19, 2023 5:33 am

igrvlhlb wrote:
Sat Mar 18, 2023 4:32 am
So far so good, but here is an important detail: the temperature sensor won't be close to the Raspberry (something within 10 meters away), so it's almost mandatory that their connection will be wireless.
"Almost mandatory" means "not mandatory". I recommend that you use a DS18B20 temperature sensor and connect it with 10 metres of four core flat telephone cable (or you can use Ethernet cable if you like). If you want a wireless interface for the temperature sensor it is possible, but you will give yourself a lot of trouble before you start.
Hmm. What can I put here?

igrvlhlb
Posts: 6
Joined: Sat Mar 18, 2023 3:57 am
Location: Rio de Janeiro, Brasil

Re: I need some help on how to make my project

Mon Mar 20, 2023 11:24 pm

Is the sim card adaptor listed as a network device? You can use hostapd and stuff to make the WiFi into an AP then treat the SIM device as the network source for DNS etc.
I guess so. It's connected through USB, as far as I can tell. It's actually a HAT, but the connection seems to be via USB. To be more precise, I'm talking about the SIM7600.
"Almost mandatory" means "not mandatory". I recommend that you use a DS18B20 temperature sensor and connect it with 10 metres of four core flat telephone cable (or you can use Ethernet cable if you like). If you want a wireless interface for the temperature sensor it is possible, but you will give yourself a lot of trouble before you start.
Yes, you're right. It looks like an interesting idea! How would that be? I would connect the sensor's pins to three of the cable's wires at one end and connect the corresponding colors to the Raspberry at the other end? Would I need to solder it?

ame
Posts: 6714
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: I need some help on how to make my project

Tue Mar 21, 2023 12:33 am

igrvlhlb wrote:
Mon Mar 20, 2023 11:24 pm
"Almost mandatory" means "not mandatory". I recommend that you use a DS18B20 temperature sensor and connect it with 10 metres of four core flat telephone cable (or you can use Ethernet cable if you like). If you want a wireless interface for the temperature sensor it is possible, but you will give yourself a lot of trouble before you start.
Yes, you're right. It looks like an interesting idea! How would that be? I would connect the sensor's pins to three of the cable's wires at one end and connect the corresponding colors to the Raspberry at the other end? Would I need to solder it?
That is basically what you do. Four core telephone cable is convenient to use, or four core alarm cable. You have to connect three wires at one end to the sensor, which might need soldering, but have a look around for alternative connection methods. At the Pi end you need three connections, and a resistor. There are lots of tutorials about this. Here's one:

https://pimylifeup.com/raspberry-pi-temperature-sensor/
Hmm. What can I put here?

deepo
Posts: 1141
Joined: Sun Dec 30, 2018 8:36 pm
Location: Denmark

Re: I need some help on how to make my project

Tue Mar 21, 2023 9:51 am

There is quite a selection of BLE temperature sensors available, many with long battery life.
The BLE refers to how they communicate their read temperatures = Bluetooth Low Energy.
Many of them transmit the read temperature regularly, which is possible to read by a Raspberry Pi (RPi's with WiFi, as Bluetooth uses the same chip and antenna as WiFi).
You need to select one that fits your temperature environment.
And preferably one that you can find info on how to decode the data you read from it.

An example could be the Xiaomi Mi Temperature and Humidity Sensor 2:
https://ndimension.design.blog/2021/12/ ... ywsd03mmc/
https://github.com/JsBergbau/MiTemperature2
https://zsitko.com/xiaomi-mijia-hygroth ... pberry-pi/

PiGraham
Posts: 5245
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: I need some help on how to make my project

Tue Mar 21, 2023 9:59 am

You can use various devices on a Pi to get mobile data but you could also consider a mobile phone Wi-Fi hotspot or a 'pocket router' / 4G router.
These may be cheaper options than a GSM HAT or similar and should solve your internet connection and local Wi-Fi requirement out of the box.
They probably have thier own power as well, which could simplify things a little bit.

igrvlhlb
Posts: 6
Joined: Sat Mar 18, 2023 3:57 am
Location: Rio de Janeiro, Brasil

Re: I need some help on how to make my project

Wed Mar 22, 2023 5:04 am

Thank you all for the replies! :)
ame wrote:That is basically what you do. Four core telephone cable is convenient to use, or four core alarm cable.
Doesn't the length of the cable affect voltage/current? Or it does affect, but too little?
Thank you for the tutorial! It's very useful. Kind of off topic, but I'd like to understand why connect the resistor to the cables connected to VCC and the other GPIO pin. I can't see that circuit schematics properly and am not sure about the current path through the cable in the middle. Is there any resource explaining it, please? I tried, but don't know how to look for it. (I understood the principle of the pull up/down resistor for a button, but the resistor in this case is unclear for me)
deepo wrote:An example could be the Xiaomi Mi Temperature and Humidity Sensor 2
Wow, that's very interesting! The only thing that keeps me from choosing it for this specific project is that as it will be operating remotely, it's better not to worry about the batteries. But i'm sure it will be useful in the near future and I'm really grateful for the time and effort you've put on gathering these resources!
PiGraham wrote:You can use various devices on a Pi to get mobile data but you could also consider a mobile phone Wi-Fi hotspot or a 'pocket router' / 4G router.
Yes, I've been looking for that too lately. One thing that worried me a little was the fact that for one USB 4G modem I read that it was recommended 5V and 2A. I remember seeing that Raspberry's USB port can output at most 1.2A. I wonder if that could bring any trouble...

ame
Posts: 6714
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: I need some help on how to make my project

Wed Mar 22, 2023 9:19 am

igrvlhlb wrote:
Wed Mar 22, 2023 5:04 am
Thank you all for the replies! :)
ame wrote:That is basically what you do. Four core telephone cable is convenient to use, or four core alarm cable.
Doesn't the length of the cable affect voltage/current? Or it does affect, but too little?
Thank you for the tutorial! It's very useful. Kind of off topic, but I'd like to understand why connect the resistor to the cables connected to VCC and the other GPIO pin. I can't see that circuit schematics properly and am not sure about the current path through the cable in the middle. Is there any resource explaining it, please? I tried, but don't know how to look for it. (I understood the principle of the pull up/down resistor for a button, but the resistor in this case is unclear for me)
You could try reading the DS18B20 datasheet.
Hmm. What can I put here?

igrvlhlb
Posts: 6
Joined: Sat Mar 18, 2023 3:57 am
Location: Rio de Janeiro, Brasil

Re: I need some help on how to make my project

Wed Mar 22, 2023 6:04 pm

ame wrote:
Wed Mar 22, 2023 9:19 am
You could try reading the DS18B20 datasheet.
Oh, I think now I get it! Could you confirm that, please? I've read this doc.
In the DC Electrical Characteristics table it says Vpu (Pullup supply) must be between 3V and Vdd when not in parasite mode. In the block diagram (Figure 3, page 5) we see that the Vpu isn't explicitly related to Vdd. What I understand is that it could even be from a source other than Vdd, as long as it is between 3V and Vdd. (Vdd is used for convenience, as Vdd is already in this range) Is that right?

I think I understood why the resistor is connected between DQ and Vdd. But I still can't understand it's effect. I've also searched for some articles like this one but I still don't get it. Do you have any suggestion?

Sorry if my questions are too basic. I have little to no background in electronics... but I want to understand what is going on, not just follow the tutorial! :D

User avatar
rpdom
Posts: 21524
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: I need some help on how to make my project

Wed Mar 22, 2023 6:38 pm

igrvlhlb wrote:
Wed Mar 22, 2023 6:04 pm
In the block diagram (Figure 3, page 5) we see that the Vpu isn't explicitly related to Vdd. What I understand is that it could even be from a source other than Vdd, as long as it is between 3V and Vdd. (Vdd is used for convenience, as Vdd is already in this range) Is that right?
Yes, that's right. Also you could have a Vdd of 5V with Vpu at 3.3V for the Pi as the 5V will never get back to the Pi GPIO.
I think I understood why the resistor is connected between DQ and Vdd. But I still can't understand it's effect. I've also searched for some articles like this one but I still don't get it. Do you have any suggestion?
The pull-up resistor is how you can have many devices sharing the same data wire for input and output.

When idle the resistor pulls the line up to 3.3V Vpu.

When a device is sending data bits it either leave the line alone (1) or pulls it down to 0V (0). If two devices try to use it at the same time it just gets pulled to 0 by both and will give an error and retry.

No device will ever pull the line directly high. The resistor does that. This prevents the case of one device outputting 3.3V while another is outputting 0V on the same wire and destroying things.
Unreadable squiggle

ghp
Posts: 3131
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany

Re: I need some help on how to make my project

Wed Mar 22, 2023 7:16 pm

a temperature sensor
What is temperature range, what is the precision needed? If it is in a vehicle, what is the medium measured (water, oil, air, exhaust, contact to a metallic surface) ?
Are there additional constraints like vibration- or shock tolerance?

Return to “Beginners”