
arcon19
-
Content Count
4 -
Joined
-
Last visited
Posts posted by arcon19
-
-
Hello everyone relative noob here. I'm currently trying to use the Adafruit ADS1015 library with a ads1114. I had the single ended read working a few days ago however its no longer working and readADC_SingleEnded locks the loop(). I'm actually using a msp430g2553 with energia, but that doesnt explain why it worked before and no longer does. Has this ever happened to anyone else before? I also posted this on Arduino forums to see if they knew anything about why this is happening.
Here is my code.#include <Wire.h> #include <Adafruit_ADS1015.h> //Adafruit_ADS1115 ads; /* Use this for the 16-bit version */ float voltage = 0.0; void setup(void) { Serial.begin(9600); Serial.println("Hello!"); Serial.println("Getting single-ended readings from AIN0..3"); Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)"); // The ADC input range (or gain) can be changed via the following // functions, but be careful never to exceed VDD +0.3V max, or to // exceed the upper and lower limits if you adjust the input range! // Setting these values incorrectly may destroy your ADC! // ADS1015 ADS1115 // ------- ------- // ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default) // ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV // ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV // ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV // ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV // ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV Wire.begin(); } void loop(void) { int16_t adc0; // adc1, adc2, adc3; Serial.print("AIN0: "); Serial.println(adc0); adc0 = readADC_SingleEnded(0); voltage = (adc0 * 0.1875)/1000; Serial.print("AIN0: "); Serial.println(adc0); Serial.print("\tVoltage: "); Serial.println(voltage, 7); Serial.println(" "); delay(200); } uint8_t m_i2cAddress=0x48; uint8_t m_conversionDelay=8; uint8_t m_bitShift=0; adsGain_t m_gain; int16_t readADC_SingleEnded(uint8_t channel) { // Start with default values uint16_t config = ADS1015_REG_CONFIG_CQUE_NONE | // Disable the comparator (default val) ADS1015_REG_CONFIG_CLAT_NONLAT | // Non-latching (default val) ADS1015_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low (default val) ADS1015_REG_CONFIG_CMODE_TRAD | // Traditional comparator (default val) ADS1015_REG_CONFIG_DR_1600SPS | // 1600 samples per second (default) ADS1015_REG_CONFIG_MODE_SINGLE; // Set PGA/voltage range config |= m_gain; Serial.println("Config is set "); // Set single-ended input channel switch (channel) { case (0): config |= ADS1015_REG_CONFIG_MUX_SINGLE_0; break; case (1): config |= ADS1015_REG_CONFIG_MUX_SINGLE_1; break; case (2): config |= ADS1015_REG_CONFIG_MUX_SINGLE_2; break; case (3): config |= ADS1015_REG_CONFIG_MUX_SINGLE_3; break; } // Set 'start single-conversion' bit config |= 0x8000; Serial.println("Single conversion bit set"); // Write config register to the ADC writeRegister(m_i2cAddress, ADS1015_REG_POINTER_CONFIG, config); Serial.println("register has been written"); // Wait for the conversion to complete delay(m_conversionDelay); Serial.println("conversion delay is over"); // Read the conversion results // Shift 12-bit results right 4 bits for the ADS1015 Serial.println("Returning the registers read"); return readRegister(m_i2cAddress, 0x00) >> m_bitShift; } byte test; static void writeRegister(uint8_t i2cAddress, uint8_t reg, uint16_t value) { Serial.println("Beginning i2c transmission"); Wire.beginTransmission(i2cAddress); Serial.println("Writing to register"); Wire.write((uint8_t)reg); Serial.println("Writting 8 bit shift"); Wire.write((uint8_t)(value>>8)); Serial.println("writing end value"); Wire.write((uint8_t)(value & 0xFF)); Serial.println("End of transmission"); test = Wire.endTransmission(true); Serial.println(test); } int16_t readRegister(uint8_t i2cAddress, uint8_t reg) { Serial.println("Reading from register"); Wire.beginTransmission(i2cAddress); Serial.println("Returning the registers read"); Wire.write((uint8_t)0x00); Wire.endTransmission(); Serial.println("requesting from i2c the registers read"); Wire.requestFrom(i2cAddress, (uint8_t)2); return ((Wire.read() << 8) | Wire.read()); }
EDIT:
So i figured out it has something to do with register writing Wire.endTransmission(); within the writeRegister call of the ADS1115 library, im not sure why.
Thanks.
-
Hi there,
Sorry about that, total noob here.
1. I am using the MSP430g2553
2. I have the RX(MSP430) to the TX of the HM-11 and vice versa
3. My current Energia version is 0101E0016
Here is a sample of my code
#include <SoftwareSerial.h> SoftwareSerial mySerial(P1_1, P1_2); // RX, TX void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } Serial.println("Hello world!"); // set the data rate for the SoftwareSerial port mySerial.begin(9600); // set master } void loop() { // run over and over // set the data rate for the SoftwareSerial port mySerial.print("test I am master "); if (mySerial.available()) { Serial.write(mySerial.read()); } if (Serial.available()) { mySerial.write(Serial.read()); Serial.println(Serial.read()); } }
Here's a link to the AT commands
https://www.seeedstudio.com/wiki/images/c/cd/Bluetooth4_en.pdf
Heres a photo of the response I'm getting from AT
My baud is set to 9600 and I'm on COM3
My ultimate goal is to connect two hm-11s using two msp430g2553s and have them communicating and seeing the communication between the two via realterm, putty etc.
-
Hello,
So I'm currently trying to setup and interface with an HM-11 Bluetooth Module and i currently cant receive any response from the module. I basically just want pass data between two of these modules using these two with one set as a master and another as a slave. Unfortunately I cannot even send AT commands and receive responses confirming that the setup is correct.
ADS1114 with Adafruit1015
in Energia - MSP
Posted
Does anyone know how to solve the Wire.endTransmission() issue? I can't use the I2C library that was written for Arduinos. I also used this same chip with an Arduino mega and it ran through the Wire flawlessly. Any help would be super helpful as I'm quite stuck and I really want to get this working since it worked the first time. Is there any reason why it may be locked up like I never ended the I2C originally when I first ran it?
Trying to use this I2C Scanner to get something but alas still no response