How to use the GPIO-Pins of the PIC32 for reading temperature?

Hello,

I'm quite new to OpenBCI and I'm using the Cyton board for my bachelor's thesis.
So far, everything works fine and now I'd like to add the possibility to measure temperature as well. My approach is to use a Cypress PSoC 1 evaluation kit for working with the temperature sensor and then add its values to the data stream from the Cyton to my laptop.
I guess I have to modify the firmware and the GUI so the temperature data is transmitted together with the data from the electrodes.
I have searched this forum and the learning section of the OpenBCI website, but I have found no information on this matter.

Basically I'm asking myself two questions:
Is it possible to use the GPIO-Pins of the PIC32 for digital communication between the boards (e.g. UART or I²C)?
If yes, which parts of the firmware and the GUI need to be modified and where can I find the source code of the firmware?

Thank you for your help, I appreciate it very much.

Comments

  • wjcroftwjcroft Mount Shasta, CA
    edited April 2018
    ES, hi.

    There are two UART serial ports on the PIC, Serial0 and Serial1. 0 is used for the link between the PIC and onboard RFduino (called the 'device', dongle RFduino is 'host). 1 is free for other uses. You can see some references to it on these past threads,


    Note that some of these threads refer to older V1 V2 firmware. Current V3 firmware I believe requires less setup for Serial1 usage.

    I2C or SPI interfacing should be possible as well, with SPI being more likely. Here's a thread on the I2C limitations.


    The right column here in the forum has two search boxes / buttons.

    Regards,

    William

  • Thank you William.

    I already used this search functions, but I'm afraid I don't see the wood for the trees.
    Anyway, I'll have a look at the firmware. If I'm not thinking in the wrong direction, it should be possible to use the Serial1 connection to integrate the temperature data into the data stream from the board.

    Do you know by any chance which part of the GUI receives the data? This needs to modified as well so I can see if the data is received.
  • wjcroftwjcroft Mount Shasta, CA
    Look over the 'Widgets' in the GUI source directory.


    These all begin with 'W'. There is one there that displays the value from an analog a/d pin. In fact, if your temperature device can produce a similar voltage level, that might be your easiest route. So you would not need to deal with serial port or SPI. Check out,



    William

  • Thank you again very much. Using the analog input could be a much better idea than my initial thought.
    I have a LM35 analog temperature sensor at hand, which produces a voltage output from -1V to 6V. Unfortunately I have found no specifications or instructions for the analog display widget. Do you know the voltage range the analog pins can tolerate?

    Although I'm quite experienced with programming, I haven't used Processing yet and I know that it can take a while to understand someone else's code. Since I haven't that much time left for my thesis, I have to ask directly instead of trying to figure it out myself. I hope you don't get the feeling I'd try to pass my work on to you.
    Is it possible to clone the analog read widget, make it a temperature widget which directly transforms the analog voltage into the temperature value and add it to the other widgets? If yes, which file of the GUI has to be modified to add this temperature widget?
  • I played a bit with the analog read widget and I'm not sure if it works. Unfortunately I wasn't able to find similar topics or some sort of tutorial on the OpenBCI websites for this matter.

    I connected my temperature sensor to GND, VDD , and D12 on the J3 connection of the Cyton board. The 3.3V are well within the input specifications for the LM35 and it produces an output voltage of 96mV, but in the analog read plot the values lie between -150 and -200. I suppose the unit of the analog read widget is mV, but I found no information confirming that.
    I don't think the reason is the connection between the sensor and the board. Although it is not as good as a soldered connection, I don't think that it is too loose to produce a reading that is that far away from the value it is supposed to read.

    I have the feeling that the solution to this is quite simple, but I have no idea how to get reasonable values from the analog read widget.
  • wjcroftwjcroft Mount Shasta, CA
    The TMP36 from Analog Devices (Adafruit link) might be a better part than the LM35 you have. It operates from 3.3 V.  Not sure about LM35.

    What about just setting up a simple voltage divider and supplying an arbitrary voltage to your analog pin, for checking operation? DO NOT go beyond the 3.3V, as that is the PIC power supply.

    The widget source is here,

  • The LM35 should be working fine with 3.3V according to the datasheet (page 4).

    I'll try to check the analog widget with other voltages.
    What I'm looking for is some documentation on that widget. There are a few questions that even the source code cannot answer. What is the unit of the value the widget shows in the GUI? Why is this value negative when I apply a positive voltage? And why does the voltage I apply on the input pin and the value in the GUI seem to be completely uncorrelated?
    Is there in the depths of the OpenBCI website or GitHub some explanation for this widget?
  • edited May 2018
    Well, I don't get it. It seems that the whole analog read widget does not make any sense.
    I applied 0V and 3.3V on the D12 input pin to get the range of the readout, but the widget does not seem to notice. The values fluctuate roughly between -150 and -200, no matter which voltage is applied to the input pin.

    Is it possible to somehow contact AJ Keller, who wrote the code for the widget?

    Or is it possible that I have to change the board mode first? If yes, how do I do that? Perhaps I missed that part, but again, I found no information on that topic.
  • wjcroftwjcroft Mount Shasta, CA
    edited May 2018
    Just looking at the code here myself, I have not tried this...

    Are you seeing a button on the screen labeled: "Turn Analog Read On"?  You should press that to tell the board to go into Analog mode.

    Have you tried other pins D11, D12, D13 are all input pins in analog mode. This widget has a number of comments suggesting you may want to add your own code.

    AJ Keller is @pushtheworld username on the forum here. He 'should' get an email notification when we mention him. But he is possibly been busy with other projects and such. You can also contact him through his website below; his email is info at pushtheworldllc.us . Let me know what you find out here back in this thread.


    Regards, William

  • Thank you again.
    Yes, I already pressed the "Turn Analog Read On" and I tested the other pins, with no better result than the D12 pin.

    I'll contact him via mail and keep this post updated.
  • So, the current status is not the best I'm afraid. I updated the firmware of the Cyton board and the two RFduino modules and now I cannot receive any data. I can start the system in the GUI, but on turning the data stream on, there's no data showing up. I'm in contact with AJ Keller and Joel Murphy and I hope that together we manage to get at least the board running again.

    My exchange is coming to an end soon, so there's not much time left to try things. Luckily my thesis could still be finished, my supervisor suggested to describe the approach in theory instead of showing a working result. I'll try to get the board running again as long as I still have access to it, however, I guess there won't be any more helpful result on using the Analog Read widget or the GPIO-Pins for serial communication for this forum entry.

    Thank you for all your help.
  • retiututretiutut Louisiana, USA
    edited May 2018
    I was able to receive data from a GSR sensor on A5 (D11) using OpenBCI_GUI 3.3.0 and the BLE dongle. One thing I noticed is that Turn Analog Read On disables the Accelerometer, and vice versa. I think this is a fair trade. 

    Next, I tried the DHT22 temperature, but stopped when I remembered that the DHT sensors use a C library to interpret the raw signal as mentioned here at the top of page three.

    Finally, I tried the the Pulse Sensor, and I did see some raw signal values come through on D11. The problem though is that the Accelerometer and the Analog read function do not update every 2 ms, as in the PulseSensorAmped_1.5.0. Update occurs ~ 3.92 ms with the GUI set to 250Hz. Thankfully, we have the Pulse Sensor Widget!!! This solves the possible timer interrupt problem. Also, the quality of the signal appears as clear as with a dedicated Arduino!

    According to the Processing code for W_AnalogRead, one can still attach external sensors to pins to D11 and D12 on the WiFi shield. In conclusion, I would try to connect sensors that output a raw signal value of some kind. The final option I would consider is have a dedicated Arduino (with DHT library) handle the temperature input from a DHT and the send simple raw signal value to the Cyton.
  • Yes, that is more or less what I tried. Unfortunately in my case the Analog Read widget did not seem to react to any voltage I applied to the pins. And the process of trying to fix it resulted in the board not sending any data.
  • retiututretiutut Louisiana, USA
    Have you contacted support @ [email protected] to resolve the issue?
  • I contacted AJ Keller who wrote the Analog Read widget and is one of the developers of the board, as far as I know.

    My idea seemed simple: Take a temperature sensor which provides an analog voltage, read that via the widget and calculate the temperature. Unfortunately that did not work. I tried the Pulse Sensor Widget, too, with equally no result.
  • wjcroftwjcroft Mount Shasta, CA
    It sounds like you had old firmware that did not support the analog pin read function. Then when you tried upgrading firmware, hit some snags. The lab should be able to walk you through the upgrade path so the widget will finally work.
Sign In or Register to comment.