Communicate with a Modbus RTU RS485 device using a Raspberry Pi

A Raspberry Pi is a tiny computer that can talk to other devices using something called Modbus protocol. This allows us to read information from these devices, like temperature values, which is very important in many industries. For example, if we want to know the temperature of a machine in a factory, we can use a Raspberry Pi to read this information and make sure the machine is working correctly. This is very helpful because it can save us time and money by detecting problems early and fixing them before they become bigger issues. Plus, a Raspberry Pi is small, cheap, and easy to use, which makes it a great tool for controlling and automating many different devices. All we need is a little bit of code, and we can read and control all kinds of machines and sensors.

To communicate with a Modbus RTU RS485 device using a Raspberry Pi, you will need to install the “pymodbus” package in your Raspberry Pi. To install the package, you can use the pip package manager with the following command:

sudo pip install pymodbus

You will also need to connect a USB to RS485 adapter to your Raspberry Pi and connect it to the Modbus RTU device. Once you have done that, you can use the following Python code to read temperature values from the device:

#!/usr/bin/env python
from pymodbus.client.sync import ModbusSerialClient
from pymodbus.register_read_message import ReadInputRegistersResponse

# Configuration
baudrate = 9600
parity = 'N'
bytesize = 8
stopbits = 1
timeout = 1
unit_id = 1
start_address = 0
num_registers = 1

# Create a Modbus client
client = ModbusSerialClient(method='rtu', port='/dev/ttyUSB0', baudrate=baudrate, parity=parity, bytesize=bytesize, stopbits=stopbits, timeout=timeout)

# Open the communication port
client.connect()

# Read temperature value from the device
response: ReadInputRegistersResponse = client.read_input_registers(start_address, num_registers, unit=unit_id)
if response.isError():
    print(f"Error: {response}")
else:
    temperature = response.registers[0] / 10.0 # assuming the temperature value is stored in a 16-bit register and multiplied by 10
    print(f"Temperature: {temperature}°C")

# Close the communication port
client.close()

This code assumes that the temperature value is stored in a 16-bit register and multiplied by 10. You may need to adjust the start_address and num_registers variables depending on the register where the temperature value is stored and the number of registers it occupies.

It's only fair to share...Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter
Share on linkedin
Linkedin

Dual ChatGPT Bots Talk to Two People at Once

Hello everyone!

Today, I am excited to share with you about my experience creating a Python program that uses ChatGPT with OpenAI’s API to maintain two separate conversations with two different people. This project was a stepping stone to my next video, where I plan to use facial recognition, speech recognition, and text-to-speech to create a bot that can hold conversations with multiple people looking and talking to it, “like a real boy.”

Dual ChatGPT Bots Talk to Two People with OpenAI API

To start, let me explain what ChatGPT is. ChatGPT is an AI language model that can be used to generate human-like responses to text prompts. It is one of the many language models available on OpenAI’s API platform. OpenAI’s API allows developers to use their state-of-the-art AI models for a variety of applications, including natural language processing, computer vision, and more.

For my project, I decided to use ChatGPT to maintain two separate conversations with two different people. I started by creating a Python script that would connect to OpenAI’s API and authenticate my credentials. I then wrote a function that would generate a response to a given text prompt using ChatGPT. Finally, I wrote the main program that would loop through the two conversations, prompting each person for a response and using ChatGPT to generate a response to each.

The program worked flawlessly, and I was able to maintain two separate conversations with two different people using ChatGPT. I was thrilled with the results and excited to see how this would tie into my next video.

In my next video, I plan to use facial recognition, speech recognition, and text-to-speech to create a bot that can hold conversations with multiple people looking and talking to it, “like a real boy.” With the help of ChatGPT, I will be able to generate human-like responses to text prompts, which will make the conversations feel more natural and engaging.

In conclusion, my experience creating a Python program that uses ChatGPT with OpenAI’s API to maintain two separate conversations with two different people was a great success. I am excited to see how this ties into my next video. Don’t forget to like the video and subscribe to my YouTube channel, for more exciting content like this.

It's only fair to share...Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter
Share on linkedin
Linkedin
Alfa LEDs

Alfa Romeo RGB Grill LEDs with Bluetooth

Update (9-12-2022)

I am now selling this for $99 + $4.99 Shipping
-Comes 12V to 5V adapter and 3 feet of wire for wiring to Car’s 12V supply
-Comes with iOS and Android Apps. 
They will ship starting: 9-30-2022
Order from the PayPal buttons below and let me know if you have any questions.

Built to ship in 1 week
___________________________________________________

The Look

I wanted to make my new Alfa stand out from the couple others I’ve seen round rarely. As if the front end of the Giulia isn’t beautiful enough. It seemed like it was a necessary and obvious mod.

The Guts & Brains

I made this 49 LED strip out of SK6812 addressable RGB LED strips. Similar to the common WS2812b strips but brighter and with a true white. Check them out here on amazon: https://www.amazon.com/gp/product/B07FVRR4KL/. I also used an Arduino Nano clone that has its own USB to serial chip built-in. Another new key component is the HC-05 serial Bluetooth module. It’s an older V2.0+EDR version of Bluetooth but it has great range. The only downside is that iOS/Apple devices don’t support 3rd party Bluetooth unless it’s made for iPhone/iPad or its the newer Bluetooth 3.0/4.0+LE

The Interface

I wanted to create a menu system and be able to hit buttons to ascii characters to change the light show modes. So far I have the default/power on mode of pure white. Then by Bluetooth you can choose “Demo” to change to an animated demo reel that comes with the LED library FastLED on the Arduino. Then I have added a Knight Rider mode. Even a special Alfa Knight Rider mode that doubles up the “V” in the grill. And finally, I have a “Fire” mode that looks like flames.

There is a menu display when you first connect with a Bluetooth terminal app on Android. I use, “Bluetooth Terminal HC-05”. It lets you assign rows of buttons to macros of strings of text to send to the device. It also allows to to see the available options in the device and you can enter, “H” to see the menu at any time.

The Code

The code is still in progress, feel free to check it out on GitHub. I hope to be updating and completing code so I can add this to my car permanently.

The Bugs & Improvements

I hope to add a few more modes and brightness control very soon. Currently the only bug in the system is the Bluetooth communication is talking to the Arduino over software serial. There are a lot of timer interupts between the FastLED library to control the lights that sometimes (30% of the time) the Bluetooth message to change a mode is missed and a different ascii character comes through. This means you have to enter the command or hit the button a couple, few times. This is easily fixed by changing over to the hardware serial UART. I have not yet done this but feel free to make a pull request for an alternative sketch.

I also have plans to design and print a circuit board to easily house the Arduino, Bluetooth module, connectors for lights and power. I have already 3D printed a couple cases to protect the guts on the road.

It's only fair to share...Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter
Share on linkedin
Linkedin

Lip-Sync Singing Skeleton for Halloween with A.I.

I’ve been getting more and more into programming with A.I. to let a computer find solutions to problems I give it with reinforcement training or a neural network and a bunch of data. It’s not as simple as it sounds. I recently found a couple music projects that use A.I. to separate vocals, drums, bass, piano and other sounds from each other into their own audio tracks. One is called Spleeter and the other is Facebook Research’s Demucs. They both use Python and TensorFlow (a popular machine learning programming library).

I wrote an application with Node.js that will take advantage of Spleeter and use Youtube to download songs from a playlist and automatically separate them and save the music tracks. Then play the original and silently watches the RMS volume of the vocals and drums to determine when to open his mouth or turn his neck.

When Halloween comes I hope to tie these to lights out front with relays and add a couple more singers to the stage.
I’m working on changing the high voltage servo for the mouth to a stepper motor with a bike brake cable for remote jaw actuation.
Take a look below to see behind the scenes of how the skeleton is controlled.

It's only fair to share...Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter
Share on linkedin
Linkedin

Web Design – WholeCellOnline.com

WholeCellOnline.com is the home of WholeCell Accessories. WholeCell is a Chicago based cell phone accessories franchise that offers cell phone, tablet and computer accessories. They are located in Joliet, Lansing, Chicago Heights, Northlake. Locations are popping up all the time.

I was contracted to find a solution to a problem. The company needed a way to look up inventory, sell items in the store and transfer/receive inventory from vendor orders, warehouse and other stores. The system is web based database driven. Technologies used to develop the system include PHP, mySQL and jQuery. The website is mainly for employees only and users must login to access inventory and store information.

Take a look to see their locations: http://wholecellonline.com

Flying FPV with a Boom Cam on a Servo

I whipped this up in an hour or two. It lets me fly FPV (first persion vision) while recording what I’m seeing live in the goggles. I added the boom camera which forced me to move the battery way back to balance it. I added the servo to look around what the HD Mobius 1080p camera that was recording video and audio. Was thinking to add a video switcher on my next newer 600mw 5.8Ghz video transmitter and 800 line camera to switch to the mobius HD camera mid-flight.

Enjoy the video,
Joe

Building Automation & Mechanical Drawing Edits

I have experience editing mechanical drawings to create a visual interactive graphic to show room temperatures and thermostat locations for building engineers. My finished products give an engineer a glimpse at a buildings temperature, humidity and set points to determine problem areas and be able to address hot/cold calls quickly.

I am Tridium Niagara Software certified and have experience with building automation software inside and out.