H7 lite + breakout+Rotarry encoder+GPS

Hi folks. I am trying to run GPS+Rotary encoder on Portenta H7 Lite with breakout, but I can not register any movement from the encoder. What am I doing wrong?

#include <Arduino_PortentaBreakout.h>
#include <TinyGPSPlus.h>

//breakoutPin pwmPins[] = {PWM0, PWM1, PWM2, PWM3, PWM4 , PWM5, PWM6 , PWM7, PWM8, PWM9};
//breakoutPin analogPins[] = {ANALOG_A0, ANALOG_A1, ANALOG_A2, ANALOG_A3, ANALOG_A4, ANALOG_A5, ANALOG_A6, ANALOG_A7};




#define rtEncdrPinA  GPIO_0 //Pins used by Encoder
#define rtEncdrPinB  GPIO_1

volatile long etEncdrPos = 0; //Encoder  possition


static const uint32_t GPSBaud = 9600; //GPS baud rate
TinyGPSPlus gps; // The TinyGPSPlus object creation

struct GPSsensorData {
  float StrLatitude;
  float StrLongitude;
  float StrhDOP;
  float StrCourse;
  float StrSpeed;
  byte StrnumberSat;
  float Deviation;
};

GPSsensorData GPSreadings; //GPSsensorData от тип GPSreadings декларирано по-горе.


void setup()
{
  Serial.begin(9600);
  Breakout.UART0.begin(GPSBaud); //Активация на Уарт0 където е свързан ГПС.
  pinMode(rtEncdrPinA, INPUT_PULLUP); // why Input_PullUP ->https://www.youtube.com/watch?v=jJnD6LdGmUo
  pinMode(rtEncdrPinB, INPUT_PULLUP);
  attachInterrupt(0, rotatorMeasurment, RISING);  //interrupt arduino with the function rotatorMeasurment using RISING to trigger when the pin goes from low to high
}

void loop()
{
GPSMeasure();  
StructPrint();
   GPSreadings.Deviation = etEncdrPos;

  smartDelay(500); // delay + feeding the GPS data into Arduino

  
}

// This custom version of delay() ensures that the gps object
// is being "fed".
static void smartDelay(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
    while (Breakout.UART0.available())
      gps.encode(Breakout.UART0.read());
  }
  while (millis() - start < ms);
}

void GPSMeasure() {  // take GPS measurments
  GPSreadings.StrLatitude = gps.location.lat();
  GPSreadings.StrLongitude = gps.location.lng();
  GPSreadings.StrhDOP = gps.hdop.hdop();
  GPSreadings.StrCourse = gps.course.deg();
  GPSreadings.StrSpeed = gps.speed.kmph();
  GPSreadings.StrnumberSat = (int)gps.satellites.value();
   if (millis() > 5000 && gps.charsProcessed() < 10)
  Serial.println(F("No GPS data received: check wiring"));
}


void rotatorMeasurment()
{
  if (digitalRead(rtEncdrPinA) == digitalRead(rtEncdrPinB)) {
    etEncdrPos++;
  } else {
    etEncdrPos--;
  }
  if (etEncdrPos >= 360) {
    etEncdrPos = etEncdrPos - 360;
  }
  if (etEncdrPos < 0) {
    etEncdrPos = etEncdrPos + 360;
  }

}

void StructPrint()
{
  Serial.print ("Recieved Latitude: ");
  Serial.println (GPSreadings.StrLatitude);
  Serial.print ("Recieved Longitude: ");
  Serial.println (GPSreadings.StrLongitude);
  Serial.print ("Recieved HDOP: ");
  Serial.println (GPSreadings.StrhDOP);
  Serial.print ("Recieved Course: ");
  Serial.println (GPSreadings.StrCourse);
  Serial.print ("Recieved Speed: ");
  Serial.println (GPSreadings.StrSpeed);
  Serial.print ("Recieved number of satellites: ");
  Serial.println (GPSreadings.StrnumberSat);
  Serial.print("Deviation: ");
  Serial.println(GPSreadings.Deviation);
}

You ask what are you doing wrong. Start with a schematic, frizzy pictures are useless. The black thing with unlabeled connections on the right is what? you have two blue modules, what are they. You show an encoder, what is it? At this point you need to post links to technical information on the hardware devices. Links to marketplace vendors such as azon are useless as they do normally include the needed technical information.

1 Like

I do not understand "frizzy", however the image is in good resolution. Maybe have a look at it? One could find out that Portenta is marked as H7 Lite, as described in the caption, and post, with breadboard, again as described. About the encoder type - is written on the label: LPD3806. The blue thing is a real enigma, I guess it will stay like that, but the other one have an antenna, so it must be the GPS. Air530 seems to be written on the label. I hope this helps.

I think the question is you do not understand what a schematic is. A frizzy (Fritzing) generates a wiring type picture that has pictures of the different modules. There are a lot of them posted mainly by people that do not understand electronics or do not want to learn how to draw a schematic. Try this link for a search term: what is an electronic schematic. CAD software to generate this ranges from very expensive to free. I use KiCad as it is a very good unrestricted package that can take you from schematic capture to PCB files.

It is understandable, it maid not be commonly accepted symbols for stylization of an electronic scheme, yet what have been posted describes the situation clear, foursquare, and in a good manner.